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 11:23:50 -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: "Michael S. Zdeb" <msz03@HEALTH.STATE.NY.US>
Content-Type:   text/plain; charset="iso-8859-1"

Thanks Mike,

I tried use tranwrd but went to a wrong way:

60 data _null_; 61 length var1 var2 $100; 62 array v(8) var2-var9; 63 var1="5365:6.82::5.82:85:::"; 64 var2=tranwrd(var1,':',': '); 65 var3=tranwrd(var1,'::',':.:'); 66 put var2= / var3=; 67 run;

var2=5365: 6.82: : 5.82: 85: : : var3=5365:6.82:.:5.82:85:.:: NOTE: DATA statement used: real time 0.00 seconds cpu time 0.00 seconds

As you can see, I tried to replace "::" with ":.:", I should have translate single ":" to ":." or ": ", as you did, instead of trying to replace "::" with ":.:", which did not work.

Kind regards,

Ya Huang

-----Original Message----- From: Michael S. Zdeb [mailto:msz03@HEALTH.STATE.NY.US] Sent: Monday, January 06, 2003 11:15 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: separate ':' delimited filed (was no subject)

Hi. Re...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.

Another idea... add a space after each delimiter...

data _null_; length var1 $100; array v(8) var2-var9; var1="5365:6.82::5.82:85:::"; do i=1 to 8; v(i)=input(scan(tranwrd(var1,':',': '),i,':'),best.); end; put (var1-var9) (=); run;

Gives...

VAR1=5365:6.82::5.82:85::: VAR2=5365 VAR3=6.82 VAR4=. VAR5=5.82 VAR6=85 VAR7=. VAR8=. VAR9=.

Mike Zdeb New York State Department of Health ESP Tower - Room 1811 Albany, NY 12237 P/518-473-2855 F/630-604-1475


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