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 (April 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 17 Apr 2008 15:57:37 -0500
Reply-To:   Yu Zhang <zhangyu05@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Yu Zhang <zhangyu05@GMAIL.COM>
Subject:   Re: data step questions
Comments:   To: Jane <program.sas@gmail.com>
In-Reply-To:   <d3de31ac0804171349i70f134f4x20ad93ffe63a8183@mail.gmail.com>
Content-Type:   text/plain; charset=ISO-8859-1

On Thu, Apr 17, 2008 at 3:49 PM, Jane <program.sas@gmail.com> wrote:

> Can I do this without using array?

you can transpose the data to a long and tall foramt, then a simple SQL or data step can get what you need. for example: the transpose the data looks like: ID _name_ vaue aa var1 2 aa var2 8 ....

bb var1 2 bb var2 9 ....

proc sql; select distinct ID from dataset order by ID where value=1; quit;

> > > On Thu, Apr 17, 2008 at 3:44 PM, Yu Zhang <zhangyu05@gmail.com> wrote: > > > an untested code, HTH. > > > > Yu > > > > > > data wanted; > > set have; > > array temp {*} var1-var30; > > call sortn(of var1- var30); > > > > do _n_=1 to hbound(temp); > > if temp(_n_)=1 then do;kp=1;leave;end; > > end; > > > > if kp ; > > drop kp; > > run; > > > > On Thu, Apr 17, 2008 at 3:31 PM, Jane <program.sas@gmail.com> wrote: > > > > > Hi all > > > > > > I have a stupid question. If I have a lot of variables, like: > > > > > > var1 var2.....var30. > > > > > > If any of them equal to 1, I want to pull out that row. Just like: > > > > > > id var1 var2 var3 var4 var5 var6 var7... > > > aa 2 8 9 4 8 9 0 > > > bb 7 1 2 5 . 0 12 > > > cc 0 2 1 .................... > > > > > > Then I can get the dataset like: > > > id > > > ---- > > > bb > > > cc > > > > > > How can I do this in some simple way? I do not need to use > > > "if..then.." for > > > 30 variables. > > > > > > Thank you very much! > > > Jane > > > > > > > >


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