BookmarkSubscribeRSS Feed
shorty_tallz
Calcite | Level 5

Hello world,

I'm currently trying output a summary of an existing dataset into a new file (containing only only the summary values).  I've tried using the class specifier to summarize (mean, sum, etc.) each variable by date, but after checking the output file, I noticed it still retained each original observation instead of summarizing by date.  Thanks in advance for any help!

-John

Here's my code (mtsudat library is already referenced): 

proc summary data = sasuser.marchflights maxdec=2 sum mean;

  class date;

  var distance mail freight boarded transferred nonrevenue passengercapacity;

output out = mtsudat.marchflights;

run;

3 REPLIES 3
OS2Rules
Obsidian | Level 7

Try:

proc summary data = sasuser.marchflights maxdec=2 sum mean;

  class date;

  var distance mail freight boarded transferred nonrevenue passengercapacity;

output out = mtsudat.marchflights (drop=_TYPE_ _FREQ_) SUM=;

run;

DLing
Obsidian | Level 7

proc summary data=sasuser.marchflights missing;     *--- missing option outputs missing class values as well;

     class date;                                    *--- you can attach formats to dates to get monthly, qtrly summaries easily;

     var x1 x2 x3;

     output out=mtsudat.marchflightsummary(drop=_:)     /*  drop _type_ _freq_  */

          sum=x1sum x2sum x3sum

          n=x1n x2n x3n

          std(x1)=x1std

     ;

run;

proc summary by default prints nothing, so maxdec=2 has no effect, nor does the mean option.  They are meaningful for PROC MEANS printed output.

Ksharp
Super User

You should use nway option and define the sum  mean ... at output statement.

proc means noprint data=sashelp.class maxdec=2 sum mean nway;
 class sex;
 var weight height;
 output out=want sum= mean= /autoname;
run;


Ksharp

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2358 views
  • 0 likes
  • 4 in conversation