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 (August 2010, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 20 Aug 2010 09:31:40 -0500
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: Read missing values with scan function
Comments: To: Samuel Escarigo <samuel.escarigo@rbs.co.uk>
In-Reply-To:  <201008201426.o7KDawqW027435@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

SCAN will ignore consecutive delimiters, and I don't know of a way to tell it not to (this is annoying sometimes, so if it's possible someone please post how!).

One thing you could do is translate '.,' to '. ,' [and every permutation of this that is possible in your data].

Like so:

data _null_; *set test; longtext= 'var1,3.,var2.54,var3.12'; longtext=tranwrd(longtext,'.,','. ,'); scan1 = scan(longtext,1,',.'); scan2 = scan(longtext,2,',.'); scan3 = scan(longtext,3,',.'); scan4 = scan(longtext,4,',.'); put longtext=; put scan1= scan2= scan3= scan4=; run;

If your data isn't harmed by it, you could just turn every ',' into ', ' and every '.' to '. ' (or ' .' if that's better); but I don't know your data to say if that's acceptable or not.

-Joe

On Fri, Aug 20, 2010 at 9:26 AM, Samuel Escarigo <samuel.escarigo@rbs.co.uk>wrote:

> Hi All, > > In the following example, where I have a string with dot and comma > delimited values, how can I read the missing value into variable scan3? > > data _null_; > set test; > longtext= 'var1,3.,var2.54,var3.12'; > scan1 = scan(longtext,1,',.'); > scan2 = scan(longtext,2,',.'); > scan3 = scan(longtext,3,',.'); > scan4 = scan(longtext,4,',.'); > put longtext=; > put scan1= scan2= scan3= scan4=; > run; > > longtext=var1,3.,var2.54,var3.12 > scan1=var1 scan2=3 scan3=var2 scan4=54 > > > As you can see, with my current code, scan3 is getting the following word > ('var2') and scan4 is 54 instead of 'var2'... > > Many thanks, > > Samuel >


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