Date: Tue, 10 Jun 2008 15:16:04 -0500 Reply-To: Tim Kynerd Sender: "SAS(r) Discussion" From: Tim Kynerd Subject: FW: reading variables enclosed in quotes Content-Type: text/plain; charset="us-ascii" OK guys, Let me try this again. (There is such a thing as solving the wrong problem.... :P) Regi, the simple way to do this, if you have Enterprise Guide, is to use the Import Data task to bring the data into SAS. Import Data will let you specify that the first line of the file contains the column names. If you don't have EG, and you know at the start how many variables (columns) you are dealing with, you could do something like this: data _null_; infile myinput '\path\to\input\file'; input var1 $var2$ var3 $; call symputx('var1',var1); call symputx('var2',var2); call symputx('var3',var3); if _n_=1 then stop; run; data mydata; infile myinput '\path\to\input\file' firstobs=2; input &var1$ &var2 $&var3$; run; This solution surely requires refinement, but it gives you something to build on. Best regards, Tim Tim Kynerd Computer Programmer/Analyst ECD/HOPE 4 Old River Place, Suite A Jackson, MS 39202 P: (601) 944-9308 F: (601) 944-0808 tkynerd@ecd.org -----Original Message----- From: Tim Kynerd Sent: Tuesday, June 10, 2008 3:05 PM To: 'rmat' Subject: RE: reading variables enclosed in quotes I recently solved this exact problem for a project. Here's what I did: data _null_; infile '\path\to\my\input\file'; file '\path\to\my\output\file'; input; if _N_=1 then _infile_ = compress(_infile_,'"'); put _infile_; run; You could also use another character variable in the last two statements in the DATA step rather than processing _INFILE_ directly, if you prefer. Best regards, Tim Tim Kynerd Computer Programmer/Analyst ECD/HOPE 4 Old River Place, Suite A Jackson, MS 39202 P: (601) 944-9308 F: (601) 944-0808 tkynerd@ecd.org -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of rmat Sent: Tuesday, June 10, 2008 2:56 PM To: SAS-L@LISTSERV.UGA.EDU Subject: reading variables enclosed in quotes Hi I am trying to read a text file containing variables enclosed in quotes like given below. There are space between variables. Can you please help me to read this data into SAS? "Name" "Age" "State" "Smith" "22" "NJ" "Tom" "44" "CT" "Shake" "34" "CA" --- --- --- --- --- Thanks very much, Regi This transmission is intended only for the use of the addressee and may contain information that is privileged, confidential, and exempt from disclosure under applicable law. If you are not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately via e-mail at support@ecd.org. 

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