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 (January 2010, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 19 Jan 2010 12:16:48 -0500
Reply-To:   Mark Miller <mdhmiller@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Mark Miller <mdhmiller@GMAIL.COM>
Subject:   Re: problem with automatic categorization of variables
Comments:   To: Emil <remilah@gmail.com>
In-Reply-To:   <c586e6aa-5c2d-432d-9097-d7ccf16b587d@30g2000yqu.googlegroups.com>
Content-Type:   text/plain; charset=ISO-8859-1

Emil,

Does the following satisfy your desire for more compact code ?

a =min(24,max(1,1+ceil((masa-15)/2))) ;

... Mark Miller

On Tue, Jan 19, 2010 at 7:57 AM, Emil <remilah@gmail.com> wrote:

> On 19 Sty, 13:03, Tom Abernathy <tom.aberna...@gmail.com> wrote: > > Emil - > > What are you trying to get the new variable B to contain? > > It almost looks like you are trying to program the MOD function. > > If you want to make 2 codes then use B=MOD(D,2) and you will get > > 0,1,0,1,1,.... > > If you want to make 3 codes then use B=MOD(D,3) ... > > I am not sure how N comes into it. > > - Tom > > > I would like to make thise code lighter > > > data n5; > set zb.all; > if masa <= 16 then a = 1; > if 16 < masa <= 18 then a= 2; > if 18 < masa <= 20 then a= 3; > if 20 < masa <= 22 then a= 4; > if 22 < masa <= 24 then a= 5; > if 24 < masa <= 26 then a= 6; > if 26 < masa <= 28 then a= 7; > if 28 < masa <= 30 then a= 8; > if 30 < masa <= 32 then a= 9; > if 32 < masa <= 34 then a= 10; > if 34 < masa <= 36 then a= 11; > if 36 < masa <= 38 then a= 12; > if 38 < masa <= 40 then a= 13; > if 40 < masa <= 42 then a= 14; > if 42 < masa <= 44 then a= 15; > if 44 < masa <= 46 then a= 16; > if 46 < masa <= 48 then a= 17; > if 48 < masa <= 50 then a= 18; > if 50 < masa <= 52 then a= 19; > if 52 < masa <= 54 then a= 20; > if 54 < masa <= 56 then a= 21; > if 56 < masa <= 58 then a= 22; > if 58 < masa <= 60 then a= 23; > if masa >60 then a = 24; > run; > > > > > > > > On Jan 19, 6:34 am, Emil <remi...@gmail.com> wrote: > > > > > On 18 Sty, 16:30, RolandRB <rolandbe...@hotmail.com> wrote: > > > > > > On 18 Jan., 14:26, Emil <remi...@gmail.com> wrote: > > > > > > > hi I need to categorize variable (let it be 'b'). I wrote this code > > > > > and i don't know what is wrong :( > > > > > > > data z1; > > > > > input p $ d t $ ; > > > > > cards; > > > > > 3 1 a1 > > > > > 3 5 a3 > > > > > 3 7 a8 > > > > > 3 9 a5 > > > > > 3 6 g2 > > > > > 3 . t1 > > > > > . 0 . > > > > > . . . > > > > > 1 4 g2 > > > > > 2 1 f1 > > > > > 2 4 1 > > > > > run; > > > > > ----------------------------------------------- > > > > > and my macro > > > > > ---------------------------------------------- > > > > > I would have 1 category (variable 'b') every 2 units (variable > 'd') > > > > > ======================================= > > > > > %macro pod( n=, l=); > > > > > data new; > > > > > set z1; > > > > > %do i=1 %to &n %by 2; > > > > > %do j=&i+2 %to &n; > > > > > %do k=1 %to &l; > > > > > if &i < d < &j then b=&k; > > > > > %end; > > > > > %end; > > > > > %end; > > > > > run; > > > > > %MEND pod; > > > > > > Get rid of the % sign in front of the words "do", "to", "by" and > "end" > > > > and it might work. > > > > > it dosn't :(- Hide quoted text - > > > > > - Show quoted text - >


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