Date: Thu, 9 Dec 2004 09:50:11 -0600
Reply-To: "Dunn, Toby" <Toby.Dunn@TEA.STATE.TX.US>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Dunn, Toby" <Toby.Dunn@TEA.STATE.TX.US>
Subject: Re: Q on extracting data from a variable
Content-Type: text/plain; charset="us-ascii"
I was wondering how many observations you have and if you are worried
about speed, if so you could drop the first scan and use a length
statement with an assignment statement such as:
Data test;
set <your data set here>;
length acct1 $1.;
Acct1 = acct;
Acct2 = scan(acct,2,'-');
Acct3 = scan(acct,3,'-');
Run;
Of course acct will need to be a numeric for this to work.
Toby
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Jim
Groeneveld
Sent: Thursday, December 09, 2004 9:48 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Q on extracting data from a variable
Hi Rahul,
It depends. If Acct is a txt file, you'll have to read it with DLM=' -'
on the INFILE statement and _no_ DSD option, and a usual INPUT
statement.
If, as I suspect, those are the contents of a character variable, you
could:
Acct1 = INPUT ( SCAN ( Acct, 1, ' -' ) , BEST12. );
and similar for Acct2 and Acct3 (1 becomes 2, resp. 3), which you could
code just once in a DO loop (with a 3-element array), or a macro %DO
loop.
Regards - Jim.
--
Y. (Jim) Groeneveld, MSc., Biostatistician, Science Team Vitatron B.V.,
Meander 1051, 6825 MJ Arnhem P.O.Box 5227, 6802 EE Arnhem, the
Netherlands
Tel: +31/0 26 376 7365, Fax: +31/0 26 376 7305
Jim.Groeneveld_AT_Vitatron.com (replace _AT_ by AT sign)
http://www.vitatron.com, http://home.hccnet.nl/jim.groeneveld
On Thu, 9 Dec 2004 07:06:39 -0800, RAHUL CHAHAL <rahulchahal@YAHOO.COM>
wrote:
>Hi,
>Would like to find out how to extract the following values of a
>variable:
>
>Acct
>1 - 1111 - 123456
>1 - 121212 - 9876543
>1 - 21212 - 909045600
>99 - 32435465 - 121
>
>Into 3 variables:
>
>Acct1 Acct2 Acct3
>1 1111 123456
>1 121212 9876543
>1 21212 909045600
>99 32435465 121
>
>Thanks for your help.
>
>Rahul
>
>
>
>
>
>
>---------------------------------
>Do you Yahoo!?
> Meet the all-new My Yahoo! - Try it today!
|