Thursday, May 8, 2008

Create a variable having value of median in categories

To find the median values of the categories (e.g. to assess test of trend)


%macro hint(var1,var2);

proc means data=fret median;
class &var1;
var &var2;
OUTPUT OUT=&var2 MEDIAN= ;
run;

data null;
set &var2;
call symputx("&var2.m"||put(_n_,1.),&var2,'g');
run;
%put &var2.m;
%put _user_;
%mend;
**depending on the number of categories (n), you would have n+1 macro variables.
**********run like this *************;
%hint(_alcoc,alc) /***_alcoc has 4 categories **/

/*** this would create macro variables as &alcm2 - &alcm(n+1)***/

data new;
set fret;

if _alcoc =. then alcm = .;
else if _alcoc =1 then alcm=&alcm2; /**note this is &alcm2 ***/
else if _alcoc =2 then alcm=&alcm3;
else if _alcoc= 3 then alcm=&alcm4;
else if _alcoc = 4 then alcm=&alcm5;

3 comments:

Anonymous said...

Tuneful well-mannered post. I honest stumbled upon your blog and wanted to say that I have exceedingly enjoyed reading your blog posts. Any conduct I' ll be subscribing to your maintain and I fancy you record again soon.
[IMG]http://www.sedonarapidweightloss.com/weightloss-diet/34/b/happy.gif[/IMG]
[img]http://www.cpcstorm.com/co/images/6.gif[/img]
[img]http://www.cpcstorm.com/co/images/7.gif[/img]
[img]http://www.cpcstorm.com/co/images/8.gif[/img]
[img]http://www.cpcstorm.com/co/images/9.gif[/img]
[img]http://www.cpcstorm.com/co/images/10.gif[/img]
[img]http://www.cpcstorm.com/co/images/11.gif[/img]
[img]http://www.cpcstorm.com/co/images/12.gif[/img]
[img]http://www.cpcstorm.com/co/images/13.gif[/img]
[img]http://www.cpcstorm.com/co/images/17.gif[/img]
[img]http://www.cpcstorm.com/co/images/18.gif[/img]

yanmaneee said...

yeezy boost 350 v2
yeezy boost 350
curry 6
curry 5
timberlands
nike huarache
vans
converse
air max 95
calvin klein underwear

Unknown said...

replica bags online pakistan replica bags forum replica bags near me