For example, I have one dataset:mydata. How to get the variable list in which var1-var4 are sorted by the descending order of their mean values?
Thanks!!
data mydata;
input var1 var2 var3 var4;
datalines;
1 2 3 4
1 3 1 6
4 5 8 9
2 8 2 2
;
run;
Hi,
data mydata;
input var1 var2 var3 var4;
xx=mean(of var1-var4);
datalines;
1 2 3 4
1 3 1 6
4 5 8 9
2 8 2 2
;
run;
proc sort data=mydata;by descending xx;run;
Thanks,
Shiva
Depend upon what you actually want. E.g., it might require something like the following if you actually want the dataset variables to be reordered:
data mydata;
input var1 var2 var3 var4;
datalines;
1 2 3 4
1 3 1 6
4 5 8 9
2 8 2 2
;
proc means data=mydata noprint;
output out=var_means(drop=_FREQ_ _TYPE_);
run;
proc transpose data=var_means out=trans_mean(rename=(_NAME_=NAME));
id _STAT_;
run;
proc sql noprint;
select name into :names
separated by " "
from trans_mean
order by mean desc
;
quit;
data want;
retain &names.;
set mydata;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.