Date: Thu, 22 Jan 2009 07:36:39 -0800
Reply-To: jerry8989@GMAIL.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: jerry8989@GMAIL.COM
Organization: http://groups.google.com
Subject: Re: Parsing SAS Variable
Content-Type: text/plain; charset=ISO-8859-1
ADD NAME=Data_null_;,
Thank you for your post it works correctly.
I'm sorry to ask another question but how can I use this code and
incorporate how to pull the data from a data set and use 2 columns
(Variables)?
I'm very very new to SAS and there are so many things involved that
I'm getting confused a bit.
Thank you
Jerry
On Jan 22, 9:26 am, iebup...@GMAIL.COM ("./ ADD NAME=Data _null_;")
wrote:
> 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.Wood...@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
>
> > jerry8...@GMAIL.C
> > OM
> > Sent by: "SAS(r) To
> > Discussion" SA...@LISTSERV.UGA.EDU
> > <SA...@LISTSERV.U cc
> > GA.EDU>
> > Subject
> > Parsing SAS Variable
> > 01/22/2009 08:44
> > AM
>
> > Please respond to
> > jerry8...@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.- Hide quoted text -
>
> - Show quoted text -
|