BookmarkSubscribeRSS Feed
Dick_Shryock
Calcite | Level 5

  

Trying to calculate various statistic for columns in a table

This question is Not Answered.

Dick.Shryock Newbie

<:section class="j-original-message"> 

Currently Being Moderated

 

I have a table with 11 columns and 31 rows the first column is a description and the rest of the columns represent various counts for each description.

What I want to do in SAS is create a table that provides the following for columns 2 - 11:

Sum

Median

Mean

Max

This is really easy to do in excel but I can't seem to figure how to do it in SAS [Version EG.5.1 (5.100.0.12019) (32-bit)]

See attached Dataset .

Thanks, Dick Shryock

Sample Output Table with Column Sum and Statistics

Date AdmitObsAMAD/CLWBSTranxLBECLDExpiredDay_Total
01/01/2013440113001100177
01/02/2013440012403000171
01/03/2013410015623000202
Total1290141027100550
Median44.00.00.0130.00.03.00.00.00.0177
Mean43.00.0.03136.70.72.30.30.00.0183
Max44011562.3100202
2 REPLIES 2
Doc_Duke
Rhodochrosite | Level 12

Dick,

To get the statistics is quite easy, to add them back to the data table is messy.

To get the statistics, use tasks --> describe --> summary statistics

and select the variables and statistics that you want.  It will produce an output report with the data.

If you want to add them to the data table, you can also select output results and it will also produce a SAS dataset with one record containing all the summary statistics for all the variables.  Then you need to rename the variables, transpose the data, and append the result to the original.

Doc Muhlbaier

Duke

Reeza
Super User

That format is going to be hard in EG, not impossible, just difficult I think. Partly I have 4.2 to test on so it may be easier in 5.1.

You ok doing code or would you rather do point and click?

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 2 replies
  • 1244 views
  • 0 likes
  • 3 in conversation