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
- /
- Base SAS Programming
- /
- output format of proc means with chosen variables

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

09-18-2016 11:38 PM

Hi,

I have 3 variables (a,b,c) for which I want to do calulate n, mean and median and then output the result.

Here is the code and the "want" output:

proc means data=have n mean median ;

var a b c ;

output out = want ;

run;

type | freq | statistic | a | b | c |

n | |||||

min | |||||

max | |||||

mean | |||||

std |

Since I want the n, mean and media I do the following adjustment:

proc means data=have n mean median ;

var a b c ;

output out = want n=n mean=mean median=median ;

run;

But here the "want" output table is of the following form:

type | freq | n | mean | median |

here the n, mean and median become columns and I get only 1 row corresponding to variable a, statistics for variables b and c simply don't show.

So is it possible to have the original form of output but for the chosen statistics, so that the "want" output table looks like this:

type | freq | statistic | a | b | c |

n | |||||

mean | |||||

median |

Thank you!

Accepted Solutions

Solution

09-20-2016
08:37 PM

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

Posted in reply to ilikesas

09-19-2016 05:39 AM

All Replies

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

Posted in reply to ilikesas

09-18-2016 11:49 PM

Try the ODS table and Google STACKODS option.

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

Posted in reply to ilikesas

09-19-2016 03:47 AM

Switching to PROC TABULATE will make a lot of this easy:

proc tabulate data=have;

var a b c;

tables n mean median, a b c;

run;

See if it comes close enough. You might want to add NMISS to the list of statistics, since you are no longer getting _FREQ_. It's not clear why you would want _TYPE_ at all, so that part is not included.

Solution

09-20-2016
08:37 PM

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

Posted in reply to ilikesas

09-19-2016 05:39 AM

3) proc univariate data=have outtable=want noprint; var a b c; run;

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

Posted in reply to ilikesas

09-19-2016 10:48 AM