turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- How do I get the summary statistics of a variable ...

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-12-2017 06:26 AM

I have a dataset in which 'Actual.balance' is a numeric column. How do I get these below summary attributes for the variable 'Actual.Balance' printed in a column with their values adjacent to it.

ColName | variable | value |

Actual.Balance | Mean | 94590150 |

Actual.Balance | Median | 107436 |

Actual.Balance | SD | 1020714752 |

Actual.Balance | NegativeCount | 14 |

Actual.Balance | Lowest | -8742115 |

Actual.Balance | Highest | 18800512187 |

Actual.Balance | Two_SD_Away | 4 |

Actual.Balance | Two_SD_Below | 0 |

Actual.Balance | Three_SD_Away | 3 |

Actual.Balance | Three_SD_Below | 0 |

Any help would be really beneficial for me.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to subhrajitcet0

12-12-2017 06:33 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-12-2017 07:18 AM - edited 12-12-2017 07:28 AM

Hi RW9, thanks for the solution. I used PROC MEANS for the same on dummy table i.e. sashelp.cars for the 'Cylinders' variable. Please find code below:

ods exclude all;

proc means data=sashelp.cars Mean Median stddev min max stackodsoutput;

var Cylinders;

ods output summary=MeansSummary;

run;

ods exclude none;

proc transpose data=MeansSummary out=meanssummary_transposed(drop=_label_ rename=(_name_=Variable Col1=value));

run;

proc sql;

alter table meanssummary_transposed

add ColName char(30);

quit;

proc sql;

update meanssummary_transposed

set Colname='Cylinders';

quit;

But I am unable to get Summary statistics as ** Negative count, two_SD_away,two_SD_below,three_SD_Away,three_SD_below** through PROC MEANS.

Could you please help?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to subhrajitcet0

12-12-2017 09:20 AM

I don't know what you mean by Negative count or one_SD_away etc.? As far as I can tell there is no such calculation, you get stddev, and if you need further processing you use that, i.e. 1 away would be = 1 * stddev, 2 would be 2 * stddev.

Also if you change yours means a bit you can avoid transposing:

proc means data=sashelp.cars; var Cylinders; output out=MeansSummary n=n mean=mean median=median stddev=stddev min=min max=max; run; data meansummary; length col1 $30; set meanssummary; col1="Cylinders"; run;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to subhrajitcet0

12-12-2017 10:49 AM

Actual.Balance | Mean | MEANS |

Actual.Balance | Median | MEANS |

Actual.Balance | SD | MEANS |

Actual.Balance | NegativeCount | FREQ + FORMAT |

Actual.Balance | Lowest | MEANS |

Actual.Balance | Highest | MEANS |

Actual.Balance | Two_SD_Away | Manual, format + FREQ or DATA STEP |

Actual.Balance | Two_SD_Below | Manual, format + FREQ or DATA STEP |

Actual.Balance | Three_SD_Away | same as above |

Actual.Balance | Three_SD_Below | same as above |

It depends on the statistics. See the table above for which procs will work for which metrics. This means you're calculating some things manually.