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 (July 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 24 Jul 2008 23:40:35 -0400
Reply-To:     "Howard Schreier <hs AT dc-sug DOT org>"
              <schreier.junk.mail@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Howard Schreier <hs AT dc-sug DOT org>"
              <schreier.junk.mail@GMAIL.COM>
Subject:      Re: create variable names from values of other variable

On Thu, 24 Jul 2008 23:25:34 -0400, Howard Schreier <hs AT dc-sug DOT org> <schreier.junk.mail@GMAIL.COM> wrote:

>On Thu, 24 Jul 2008 17:31:46 -0700, learner <cnfengshuang@GMAIL.COM> wrote: > >>Hi, >> >>What I want to do is like this. Suppose I have some data as below. >> >>id date value >>1 200801 100 >>2 200802 101 >>3 200803 99 >> >>I want to create a new variable each time value>=100, with part of the >>variable name record the date. like this: >> >>id date value value_200801 value_200802 >>1 200801 100 100 101 >>2 200802 101 100 101 >>3 200803 99 100 101 >> >>I have a large data set to process like this, so please help me to >>find an easy way to do it. I am going to do numerical analysis for >>each id, and need to drop the added variables in the process of >>calculation before processing the next id, to save system resource. >>Can I do this in the DATA step? or is IML better? >> >>TIA >>Learner > >Try this: > > data have; > informat id $1. date yymmn6.; > format date yymm7.; > input >id date value ; cards; >1 200801 100 >2 200802 101 >3 200803 99 > ; > > data ge100; > set have; > where value ge 100; > run; > > proc transpose data=ge100 out=wide(drop=_name_) prefix=value_; > id date; > var value; > run;

Or combine the above 2 steps as:

proc transpose data=have out=wide(drop=_name_) prefix=value_; where value ge 100; id date; var value; run;

> > data want; > set have; > if _n_=1 then set wide; > run;


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