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 (August 2006, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 3 Aug 2006 10:52:12 -0700
Reply-To:   SAS LEARNER1 <kappel_chris@YAHOO.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   SAS LEARNER1 <kappel_chris@YAHOO.COM>
Organization:   http://groups.google.com
Subject:   Re: dire need of help!!
Comments:   To: sas-l@uga.edu
In-Reply-To:   <1154490211.688662.62080@i42g2000cwa.googlegroups.com>
Content-Type:   text/plain; charset="iso-8859-1"

Thanks a lot!! dramage wrote: > I think the requirement for macros is 'complexifying' the issue. > Nevertheless, here is my solution. > > ========================================================= > data state; > input state $ index subcat id; > datalines; > MN 5 1 40 > MN 5 2 30 > MN 5 3 35 > ID 6 1 44 > ID 6 2 34 > CO 7 3 33 > CO 7 5 32 > AL 9 1 48 > AL 9 5 55 > AL 9 3 22 > ME 8 2 44 > ME 8 1 33 > ; > run; > > %macro st(st,cat); > > %global ncat; > > %if &st=MN %then %do; > %let ncat=%eval(&cat*2); > %end; > %else %if &st=ID %then %do; > %let ncat=%eval(&cat*3); > %end; > %else %do; > %let ncat=; > %end; > > run; > > %mend st; > > data final; > set state; > call execute('%st('||state||','||subcat||')'); > > ncat=resolve('&ncat'); > > run; > > proc print data=final; run; > > ========================================================= > SAS LEARNER1 wrote: > > Hi all! > > > > I am stuck up with the problem of solving this problem only by using > > 'MACROS'. The problem is one I posted today morning but the set of > > questions are as below:- > > > > input state $ index subcat id; > > datalines; > > MN 5 1 40 > > MN 5 2 30 > > MN 5 3 35 > > ID 6 1 44 > > ID 6 2 34 > > CO 7 3 33 > > CO 7 5 32 > > AL 9 1 48 > > AL 9 5 55 > > AL 9 3 22 > > ME 8 2 44 > > ME 8 1 33 > > ; > > > > 1) Create a macro program, which will read the value of state as a > > macro variable 'st'. > > 2) The macro will do following computations through data steps: > > a) Read the value of macro variable 'st'. > > b) Compare it with two states 'MN' and 'ID'. > > c) If the value of macro variable 'st' is 'MN' then the program will > > multiply the variable 'subcat' by 2 and will create a new variable > > called 'ncat'. > > d) If the value of macro variable 'st' is 'ID' then the program will > > multiply the variable 'subcat' by 3 and will create a new variable > > called 'ncat'. > > > > 3) It will print the dataset with values of 'ncat'. > > > > I am really new to this topic and dont understand well about 'macros'. > > If someone would show me the way forward as how to create/write macros > > for this problem, I would be highly appreciative. > > > > Looking forward to your help! > > > > Regards, > > chris


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