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 (July 2007, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 1 Jul 2007 11:05:13 -0500
Reply-To:     Kevin Myers <kmyers1@CLEARWIRE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Kevin Myers <kmyers1@CLEARWIRE.NET>
Subject:      Re: INFILE DSD and quotation mark as data
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
              reply-type=original

My solution is similar to Peter's, except that you wouldn't need to post-process the data after reading it to undo the prior translation:

data foo; infile cards dsd dlm=',' missover ; length a1-a10 $10; input @; _infile_ = tranwrd( _infile_, "'","""'"""); input a1-a10 ; cards; 1,2,3,4,5,6,7,8,9,0 1,,3,,5,,7,,9, 1,,,4,,,7,,,0 1,,,',,,',,,' run;

HTH, s/KAM

----- Original Message ----- From: "Peter" <crawfordsoftware@gmail.com> To: <sas-l@uga.edu> Sent: Sunday, July 01, 2007 10:45 Subject: Re: INFILE DSD and quotation mark as data

> On Jul 1, 3:57 pm, "Richard A. DeVenezia" <rdevene...@wildblue.net> > wrote: >> Some comma separated data elements are to be read in. >> None of the data elements contain commas, thusly none of the data >> elements >> are quoted. Adjacent delimiters are to be considered missing, and some >> data >> elements are a single single quote (SSQ). >> >> If DSD is notused >> INPUT will not 'read' a missing value for the variable when there are >> adjacent delimiters >> The SSQ is read (but it ends up in the wrong variable) >> >> If DSD is used >> INPUT will 'read' a missing value for the variable when there are >> adjacent delimiters >> The SSQ causing reading to proceed to a closing SSQ, going past a >> comma >> that is supposed to delimit. >> >> Any INFILE options to work around this ? >> >> ---------- >> data foo; >> infile cards dlm=',' missover ; >> length a1-a10 $10; >> input a1-a10; >> cards; >> 1,2,3,4,5,6,7,8,9,0 >> 1,,3,,5,,7,,9, >> 1,,,4,,,7,,,0 >> 1,,,',,,',,,' >> run; >> >> * row 4 column 4 is read in as ,,, >> * want it to be a single , >> *; >> data foo; >> infile cards dsd dlm=',' missover ; >> length a1-a10 $10; >> input a1-a10; >> cards; >> 1,2,3,4,5,6,7,8,9,0 >> 1,,3,,5,,7,,9, >> 1,,,4,,,7,,,0 >> 1,,,',,,',,,' >> run; >> ---------- >> >> -- >> Richard A. DeVeneziahttp://www.devenezia.com/ > > that looks like a defect. (either data or sas-internals) > I was under the impression that the "quoted" string feature depended > on double quotes, not singles. > > Until the defect is remedied, here is a possible work-around, using > translate() from single quotes to 01x and back > > data foo; > infile cards dsd dlm=',' missover ; > length a1-a10 $10; > input @; > _infile_ = translate( _infile_, "01"x, "'" ); > input a1-a10 ; > array a a1-a10 ; > do over a; > a= translate( a, "'", "01"x ); > end; > cards; > 1,2,3,4,5,6,7,8,9,0 > 1,,3,,5,,7,,9, > 1,,,4,,,7,,,0 > 1,,,',,,',,,' > run; > > > PeterC > >


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