BookmarkSubscribeRSS Feed
SIMMII
Calcite | Level 5

Hi,

 

I recently started using SAS studio for my economic data analysis course, and I've been trying to sort the variables by descending mean. My code is shown in the pictures below, however the log is giving the message also shown in the picture below. Please let me know what is wrong with my code, and how I can fix it.

 

Thank you!!

Questionforquestionb.PNG

Questionforquestionb2.PNG

Questionforquestionb3.PNG

1 REPLY 1
Tom
Super User Tom
Super User

If you just want the MEAN statistic then either subset the current summary dataset you have generated.  You could add a WHERE statement to your PROC TRANSPOSE step.

where _stat_='MEAN';

Or you could just generate only the MEAN statistic into the summary dataset by changing the OUTPUT statement.

proc means .... ;
  var x1-x34 ;
  output out=mean_summary mean=;
run;

That will make a dataset with only one observation with variables names X1-X34 that contain the MEAN value of the respective original variables.

 

Try it yourself:

proc summary data=sashelp.class;
  var age height weight;
  output out=stat1;
  output out=stat2 mean=;
run;

proc print data=stat1; run;
proc print data=stat2; run;

proc transpose data=stat1 out=tran1;
  var age height weight;
  where _stat_='MEAN';
run;

proc transpose data=stat2 out=tran2;
  var age height weight;
run;

proc print data=tran1;
run;
proc print data=tran2;
run;

TRAN1 and TRAN2 have the same results.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 644 views
  • 0 likes
  • 2 in conversation