LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2007, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 17 Dec 2007 11:50:20 -0600
Reply-To:     "data _null_," <datanull@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "data _null_," <datanull@GMAIL.COM>
Subject:      Re: writing a file
Comments: To: mpajoh@odot.org
In-Reply-To:  <OF5C88FB0C.83F9E6C5-ON862573B4.005FEF61-862573B4.006068FA@fd9ns01.okladot.state.ok.us>
Content-Type: text/plain; charset=ISO-8859-1

Masoud pointed out that the method I proposed does not work well with missing character variables. This is similar and should solve that problem.

filename ft44f001 temp lrecl=32767; data _null_; set sashelp.class; if mod(_n_,2) eq 0 then call missing(of _character_); else call missing(of _numeric_); file ft44f001 dsd; put (_all_) (:) @; _file_ = cats('"',tranwrd(_file_,',','","'),'"'); put; run;

data _null_; **look at it; infile ft44f001; input; list; run; proc import datafile=ft44f001 out=work.class dbms=csv replace; getnames=no; run; proc print; run;

On Dec 17, 2007 11:33 AM, <mpajoh@odot.org> wrote: > > I tried this. > One question, why does this not list the variables that are blank fro all > observations? > Is there a way to have this? > "John Smith","", "555-1234","","123 Elm St.","Somewhere, CA 11111", "" > > Thanks. > > Masoud > > > > > "data _null_," <datanull@gmail.com> > > > 12/17/2007 10:50 AM > Tompajoh@odot.org > cc > SubjectRe: writing a file > > > > > > > > Be sure to use a permanent file I used TEMP in my example. > > On Dec 17, 2007 10:44 AM, <mpajoh@odot.org> wrote: > > > > This is excellent. > > Thanks for quick reply. > > I will try it as soon as I get a chance. > > > > Masoud > > > > > > > > > > > > "data _null_," <datanull@gmail.com> > > > > 12/17/2007 10:36 AM > > Tompajoh@odot.org > > ccSAS-L@listserv.uga.edu > > SubjectRe: writing a file > > > > > > > > > > > > > > > > This assumes that your data contain no double quotation marks, and > > that it will fit via CAT in a line less than or equal to 32767. And > > that you are happy with BEST format for numeric variables. Do you > > need the variable names in row 1? Are you needs actually more complex > > than you state? > > > > filename ft44f001 temp lrecl=32767; > > data _null_; > > set sashelp.class; > > file ft44f001; > > _file_ = cats('"',catx('","',of _all_),'"'); > > put; > > run; > > > > > > data _null_; **look at it; > > infile ft44f001; > > input; > > list; > > run; > > > > On Dec 17, 2007 10:03 AM, Masuod Pajoh <mpajoh@odot.org> wrote: > > > I need to write a file, from a SAS data set, in the following format: > > > "var1","var2","var3","var4", . . . ,"varN" > > > this is regardless if the variable is numeric or character, > > > and each output line contains all the variables in the SAS data set. > > > > > > Is there an easy, may be a macro, way? > > > > > > Masoud > > > I use XP_PRO and SAS v.9.1.3 > > > > > > > > >


Back to: Top of message | Previous page | Main SAS-L page