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 (January 2003, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 6 Jan 2003 10:49:57 -0800
Reply-To:   "Huang, Ya" <yhuang@AMYLIN.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Huang, Ya" <yhuang@AMYLIN.COM>
Subject:   Re: separate ':' delimited filed (was no subject)
Comments:   To: "Liu, Guoyi" <LiuG@NJC.ORG>
Content-Type:   text/plain; charset="iso-8859-1"

Guoyi,

Unfortunately, scan function treat contiguous delimiters as one, therefore, simply scan by ':' won't work. But we can do some preparation before we feed the data to scan:

17 data _null_; 18 length lvar $100; 19 Var1="5365:6.82::5.82:85:::"; 20 lvar=''; 21 do i=1 to length(var1); 22 if i< length(var1) and substr(var1,i,2)='::' then 23 lvar=compress(lvar||substr(var1,i,1)||'.'); 24 else lvar=compress(lvar||substr(var1,i,1)); 25 end; 26 put var1= / lvar=; 27 array v(8) var2-var9; 28 do i=1 to 8; 29 v(i)=input(scan(lvar,i,':'),best.); 30 end; 31 put (var2-var9) (=); 32 run;

Var1=5365:6.82::5.82:85::: lvar=5365:6.82:.:5.82:85:.:.: var2=5365 var3=6.82 var4=. var5=5.82 var6=85 var7=. var8=. var9=.

The first do loop translate "::" into ":.:", so that the second do loop can use scan() to separate the fields.

Hope this helps

BTW, next time, put some subject line in your post, so that may not delete it by default.

Ya Huang

-----Original Message----- From: Liu, Guoyi [mailto:LiuG@NJC.ORG] Sent: Monday, January 06, 2003 9:31 AM To: SAS-L@LISTSERV.UGA.EDU Subject:

Hi all, Happy new year! This is Guoyi Liu from Colorado, I posted a question to listserv several month ago. I have a question about SAS data management aagain, I am not sure if someone could help me again. My queston is below.

Var1="5365:6.82::5.82:85:::" Format is Char.

between two ':' there is a missing value. How can I seperate them to

var2 var3 var4 var5 var6 var7 var8 var9 5365 6.82 . 5.82 85 . . .

Thank you very much.

Guoyi.


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