LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (October 2007, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 2 Oct 2007 09:32:25 -0400
Reply-To:     "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject:      Re: Conditional PROCessing

On Fri, 28 Sep 2007 17:29:06 -1000, Hassan Eini <einizinab@GMAIL.COM> wrote:

>Alohas Folks, > >Just I wanted to know whether I can do a conditional processing of the >following code: > >////////////////////////////////////////////// > >data newdata; set Orgdata; > >*model*=1; > >run; > >proc means data=newdata; > >var URBAN Education Age; > >class year; > >weight neweight; > >run; > >*//////////////////////////////////* > >*I want mean of variable URBAN if model is 1, URBAN and Education if model >is 2, and Urban, Education and Age if model is 3. I will manually change the >input value of "model".* > >* **Your inputs are really appreciated.* > >*With all the best Alohas and nice weekend,* > >*Hassan*

Creating a new data set with an additional data set variable (MODEL) having an invariant value does not really do much good. Instead, use a macro variable as in

%let model=2;

Then the variable list can be derived using something like

%let varlist = %sysfunc( choosec(&model,age,age height,age height weight) );

This only works because the models are designated 1/2/3. If it were A/B/C it would be harder.

Test:

proc means data=sashelp.class; var &varlist; run;

Result:

Variable N Mean Std Dev Minimum Maximum ------------------------------------------------------------------------- Age 19 13.3157895 1.4926722 11.0000000 16.0000000 Height 19 62.3368421 5.1270752 51.3000000 72.0000000 -------------------------------------------------------------------------


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