BookmarkSubscribeRSS Feed
mroungou
Calcite | Level 5

Hello, I have been trying to sort my means after computing them with the PROC MEANS function. I used the same code for the a slightly different problem. When I use the proc sort function, it tell me my variable does does exist. Any ideas?

 

Screenshot 2021-02-13 at 4.38.25 PM.png

4 REPLIES 4
JackHamilton
Lapis Lazuli | Level 10

Run a PROC CONTENTS to see what variables are actually in the data set you want to sort.  

JackHamilton
Lapis Lazuli | Level 10

I am curious why you decided to use the ODS OUTPUT statement instead of the more traditional OUTPUT statement.

 

Look at the program below and make sure you understand the differences and similarities in the print output and data sets.

/**********/
title 'proc means ods_output_stackodsoutput';
ods output summary=ods_output_stackodsoutput;
proc means data=sashelp.class mean sum std stackodsoutput;
    var age height;
run;

title 'means output ods_output_stackodsoutput';
proc print data=ods_output_stackodsoutput; run;


/**********/
title 'proc means ods_output_nostackodsoutput';
ods output summary=ods_output_nostackodsoutput;
proc means data=sashelp.class mean sum std ;
    var age height;
run;

title 'means output ods_output_nostackodsoutput';
proc print data=ods_output_nostackodsoutput; run;


/**********/
title 'proc means means_output_stackodsoutput';
proc means data=sashelp.class mean sum std stackodsoutput;
    var age height;
    output out=means_output_stackodsoutput;
run;

title 'means output means_output_stackodsoutput';
proc print data=means_output_stackodsoutput; run;


/**********/
title 'proc means means_output_nostackodsoutput';
proc means data=sashelp.class mean sum std ;
    var age height;
    output out=means_output_nostackodsoutput;
run;

title 'means output means_output_nostackodsoutput';
proc print data=means_output_nostackodsoutput; run;

I moved the ODS OUTPUT statements outside the PROC MEANS statements because the ODS OUTPUT statement is not part of PROC MEANS procedure.

 

 

mroungou
Calcite | Level 5
To be honest, I'm new to SAS and my professor gave us a challenging assignment to do so I am somewhat figuring out how to use the different functions and when. I'll take a look at the code you provided and do some research to better understand. Thanks for the help!
JackHamilton
Lapis Lazuli | Level 10

A few comments:

 

I'm not a statistician, so I don't know how statisticians think, but in the business world you almost never want to run MEANS or SUMMARY (or REPORT or TABULATE) without the MISSING keyword, because you almost never want to just throw away data.  You want your totals to add up to the same numbers.

 

It's a matter of preference, but I almost never use PROC MEANS.  If I want "printed" output, I create a data set with PROC SUMMARY and then print it using PROC PRINT or TABULATE or REPORT.  Those procedures are more flexible and produce better looking output.  In general, REPORT and TABULATE are really useful to know, because they can produce complex output without a lot of programming on your part.

 

Also, none of your code contains what SAS calls a "function". PROC MEANS is a procedure, not a function.  MEAN is the name of a function, and also of a statistic/keyword.  Your code uses MEAN as a keyword, not as a function.  Even in a PROC SUMMARY statement like OUTPUT OUT=XYZ MEAN(abc)=ABC_MEAN , the word MEAN is a keyword, even though it looks like a function.  

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1352 views
  • 0 likes
  • 2 in conversation