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
- /
- descriptive statistics

Topic Options

- Subscribe to 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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-10-2013 08:13 AM

Hi

I am a beginner. I need some help with tables format. i have multiple years of data. I am able to calculate descriptive statisics using proc means command.

proc means data=data.source;

var x1 x2;

class year;

run;

My output table looks like this

N mean std dev minimum maximum

class variable year x1

x2

However I want only variable means as columns and class variable as rows in my output table, like

N x1 x2

Class variable

Your suggestions will be highly appreciated

Thanks in advance

Accepted Solutions

Solution

06-10-2013
09:19 AM

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

06-10-2013 09:19 AM

I believe wants just x1 and x2 variable columns to be the mean and the n column to be the observations (which assumes that both variables means have the same number of obs). The output dataset route could be mimic this way (I keep the n's for both variable just in case there are different):

proc summary data=sashelp.cars n mean;

class make;

var invoice enginesize;

output out= test n=inv_n eng_n mean=inv_mean eng_mean;

run;

data test2;

set test;

where _type_ > 0;

drop _type_ _freq_;

run;

EJ

All Replies

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

06-10-2013 08:26 AM

Sounds like you want to check out proc report or proc tabulate. You can tell proc means which stats to output (proc means data=ds n means etc..) but I dont think the layout is has customization that you are looking for.

EJ

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

06-10-2013 08:36 AM

Hi.

You could use an output statement to output in a SAS data set the statistic you need (the mean) and then use proc transpose to re-arrange your dataset as you want:

*below I use the sashelp.class data set to calculate the average age by sex;

proc means data = sashelp.class **mean;*I only want the mean;**

var age;

class sex;

**output out = means(drop = _TYPE_ _FREQ_) mean = avg; *here I output a SAS data set named means and I label the variable mean as avg;**

run;

***now transpose the data set;**

proc transpose data = means out = t_means;

where sex ne "";

var avg;id sex;

run;

Is this something you want?

Good luck,

Anca.

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

06-10-2013 08:49 AM

Hi,

You simply need to use Proc Summary with Output Out statement...There is no need to re-arrange the data as per your requirement...

**proc** **summary** data = test print;

class year;

var x1 x2;

output out = test_stat(where = (_type_ > **0**));

**run**;

-Urvish

Solution

06-10-2013
09:19 AM

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

06-10-2013 09:19 AM

I believe wants just x1 and x2 variable columns to be the mean and the n column to be the observations (which assumes that both variables means have the same number of obs). The output dataset route could be mimic this way (I keep the n's for both variable just in case there are different):

proc summary data=sashelp.cars n mean;

class make;

var invoice enginesize;

output out= test n=inv_n eng_n mean=inv_mean eng_mean;

run;

data test2;

set test;

where _type_ > 0;

drop _type_ _freq_;

run;

EJ

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

06-10-2013 12:07 PM

Thank you all. I really appreciate your help.