Date: Thu, 22 Jan 2009 09:31:05 -0500
Reply-To: Nathaniel.Wooding@DOM.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <Nathaniel.Wooding@DOM.COM>
Subject: Re: Parsing SAS Variable
In-Reply-To: <ce1fb7450901220626k4cac498bsc3da28b26491708@mail.gmail.com>
Content-type: text/plain; charset=US-ASCII
Null
Thanks for catching that. He sent me a note off line pointing this out and
I sent him a solution similar to yours
Nat
Nat Wooding
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977
"./ ADD NAME=Data
_null_;"
<iebupdte@gmail.c To
om> Nathaniel.Wooding@dom.com
cc
01/22/2009 09:26 SAS-L@listserv.uga.edu
AM Subject
Re: Parsing SAS Variable
Nat,
The OPs example need looks like Cartesian product which could be done as...
Data one(keep=s1 s2);
set one;
length s1 $2 s2 $4 ;
do i = 1 by 1;
s1 = scan(col1,i);
if missing(s1) then leave;
do j = 1 by 1;
s2 = scan(col2,j);
if missing(s2) then leave;
output;
end;
end;
run;
Best regards, data _null_;
On 1/22/09, Nat Wooding <Nathaniel.Wooding@dom.com> wrote:
> Jerry
>
> Try the following. Note that I added a second obs that was longer than
the
> one in the first.
>
> Data one;
> LENGTH COL1 COL2 $ 35;
> col1 = 'X5 X8 X12 X9 X1';
>
> Col2 ='1990 1991 1992 1993 1994';
> output;
>
>
> col1 = 'X7 X6 X52 X4 X3 X2 X1';
>
> Col2 ='2990 2991 2992 2993 2994 2666 3333';
> output;
> run;
> Data one;
> set one;
> length s1 $2 s2 $4 ;
> _I_ = 0 ;
> Drop _I_ col1 col2;
> Do until( s1 ='' );
> _I_ + 1;
> s1 = scan( col1 , _I_ );
> s2 = scan( col2 , _I_ );
> if s1 gt '' then output;
> end;
> run;
>
> Nat Wooding
> Environmental Specialist III
> Dominion, Environmental Biology
> 4111 Castlewood Rd
> Richmond, VA 23234
> Phone:804-271-5313, Fax: 804-271-2977
>
>
>
> jerry8989@GMAIL.C
> OM
> Sent by: "SAS(r) To
> Discussion" SAS-L@LISTSERV.UGA.EDU
> <SAS-L@LISTSERV.U cc
> GA.EDU>
> Subject
> Parsing SAS Variable
> 01/22/2009 08:44
> AM
>
>
> Please respond to
> jerry8989@GMAIL.C
> OM
>
>
>
>
>
>
> I have SAS data set with 2 columns(Variables) that have data that is
> laid out like this
>
> Column1
> X5 X8 X12 X9 X1
>
> Column2
> 1990 1991 1992 1993 1994
>
> I have no control on how many values that can be in 1 cell. There
> could be 1 or 20.
> I need to know if it's possible to break this data out so it appears
>
> 1990 X5
> 1991 X5
> 1992 X5
> 1993 X5
> 1994 X5
> 1990 X8
> 1991 X8
> 1992 X8
> 1993 X8
> 1994 X8
> etc....
>
> I'm very new to SAS and I would appricate any help I can get.
>
> Thank You
> Jerry
>
>
> CONFIDENTIALITY NOTICE: This electronic message contains
> information which may be legally confidential and/or privileged and
> does not in any case represent a firm ENERGY COMMODITY bid or offer
> relating thereto which binds the sender without an additional
> express written confirmation to that effect. The information is
> intended solely for the individual or entity named above and access
> by anyone else is unauthorized. If you are not the intended
> recipient, any disclosure, copying, distribution, or use of the
> contents of this information is prohibited and may be unlawful. If
> you have received this electronic transmission in error, please
> reply immediately to the sender that you have received the message
> in error, and delete it. Thank you.
>
|