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 (September 2004, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 29 Sep 2004 15:15:11 -0400
Reply-To:     Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject:      Re: Infile for csv file where char variable contains inbedded
              comma

Whoever prepared the data did not follow the CSV conventions. The preferred solution is to go back and get it done correctly.

Here is a quick fix which works on the example. Precede the INPUT statement with

input @; _infile_ = tranwrd(_infile_,'""','"');

That will get rid of the doubled double quotes. However, if the real data file has values which include such quotation marks, this will cause trouble and something more elaborate will be needed.

On Thu, 23 Sep 2004 17:59:48 -0500, Chuck Enright <chuck_sas@CFEDATA.COM> wrote:

>In the following data step, variable VAR12 contains an inbedded comma in the >value and the variable is wrapped with 2 sets of double quotes. How do I >modify the infile, informat, or input statement to read the value with the >comma and exclude the quote? > >Desired output >VAR12 = 123 MAIN TREET, LOT 126 TR > > >DATA TEST; > INFILE DATALINES MISSOVER DSD; > > INFORMAT > VAR01 $20. > VAR02 8. > VAR03 MMDDYY8. > VAR04 $20. > VAR05 $8. > VAR06 8. > VAR07 8. > VAR08 8. > VAR09 MMDDYY8. > VAR10 $35. > VAR11 $4. > VAR12 $100. > VAR13 $10. > VAR14 $28. > VAR15 $2. > VAR16 $10. > VAR17 $25. > VAR18 $1. > VAR19 $5. > VAR20 COMMA15.2 > VAR21 COMMA15.2 > VAR22 $10. > VAR23 COMMA15.2 > VAR24 8. > VAR25 $100. > VAR26 $25. ; > > INPUT > VAR01 $ VAR02 VAR03 VAR04 $ VAR05 $ VAR06 VAR07 > VAR08 VAR09 VAR10 $ VAR11 $ VAR12 $ VAR13 $ VAR14 $ > VAR15 $ VAR16 $ VAR17 $ VAR18 $ VAR19 $ VAR20 VAR21 > VAR22 $ VAR23 VAR24 VAR25 $ VAR26 $ > ; >datalines; >"ABCDEFGHIJKLM","1234","01/01/04","ABC123456789","Q12345","315.00","0","10" ,"01/23/04","Completed","A123",""123 >MAIN TREET, LOT 126 >TR"","n/a","DALLAS","TX","11111","COUNTY","Y","O","30000.00","26000.00","", "35000.00","16.67","No >Reason","ABC" >; >RUN;


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