This question is Not Answered.
Dick.Shryock Jul 10, 2013 9:57 AM
<: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 | Admit | Obs | AMA | D/C | LWBS | Tranx | LBEC | LD | Expired | Day_Total | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|
01/01/2013 | 44 | 0 | 1 | 130 | 0 | 1 | 1 | 0 | 0 | 177 | ||
01/02/2013 | 44 | 0 | 0 | 124 | 0 | 3 | 0 | 0 | 0 | 171 | ||
01/03/2013 | 41 | 0 | 0 | 156 | 2 | 3 | 0 | 0 | 0 | 202 | ||
Total | 129 | 0 | 1 | 410 | 2 | 7 | 1 | 0 | 0 | 550 | ||
Median | 44.0 | 0.0 | 0.0 | 130.0 | 0.0 | 3.0 | 0.0 | 0.0 | 0.0 | 177 | ||
Mean | 43.0 | 0.0 | .03 | 136.7 | 0.7 | 2.3 | 0.3 | 0.0 | 0.0 | 183 | ||
Max | 44 | 0 | 1 | 156 | 2 | .3 | 1 | 0 | 0 | 202 |
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
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?
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!
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.