descriptive statistics

Solved
Occasional Contributor
Posts: 8

descriptive statistics

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

Accepted Solutions
Solution
‎06-10-2013 09:19 AM
Super Contributor
Posts: 334

Re: descriptive statistics

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
Super Contributor
Posts: 334

Re: descriptive statistics

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

Super Contributor
Posts: 543

Re: descriptive statistics

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.

Regular Contributor
Posts: 195

Re: descriptive statistics

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
Super Contributor
Posts: 334

Re: descriptive statistics

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

Occasional Contributor
Posts: 8

Re: descriptive statistics

Thank you all. I really appreciate your help.

🔒 This topic is solved and locked.