Programming the statistical procedures from SAS

Proc Means: Getting the same information in both html and data set outputs

Accepted Solution Solved
Reply
Contributor
Posts: 53
Accepted Solution

Proc Means: Getting the same information in both html and data set outputs

Hi,

I have my PROC MEANS output destination set to html. I am also trying to create a data set that has the same information as what appears in the html output and vice versa. However, the html output has things that I want in the data set and the data set has things I would like in the html output, but I can't seem to program PROC MEANS to make BOTH the html and data set to have the same information.  Could some one enlighten me how to do this easily, if it is at all possible to be done easily.

The following is my sas code using the attached sample data. Running the code, I get the sample_stats data set, which is also attached.

proc means data=sample n mean median stddev max min skew kurtosis prt;

  var clean_ret dirty_retb2;

  class bindx_cat;

  output out=sample_stats;

* output out=sample_stats n= mean= median= stddev= max= min= skew= kurtosis= prt=/autoname;

  title "Sample statistics";

run; title;

I get the following html output.

Capture1.JPG

... and the data set has the following data:

Capture2.JPG

Notice the differences between these two outputs:

1. the html does not give the statistics of the full sample, but only of the INVESTMENT and NON-INVEST sub-samples. The data set, on the other hand, does give statistics of the full sample (_TYPE_ = 0 ).

2. the html gives all the statistics I asked for in the first line of the PROC MEANS code, but the data set does not.

I tried using the output statement that has been commented out in the sas code, but it is complicated to put this alternative data set in the format that I want, which is the way the html output appears.

Can any one help me solve this problem.

Thanks in advance!!

Attachment
Attachment

Accepted Solutions
Solution
‎01-28-2013 09:07 AM
Super Contributor
Posts: 543

Re: Proc Means: Getting the same information in both html and data set outputs

HI,

you could use and ODS OUTPUT statement instead of OUTPU, something like this (I also incorporate the nice 'types ..()' as suggested by EJ above.

(I am using sashelp.class as an example)

proc means data=sashelp.class n mean median stddev max min skew kurtosis prt;

  var age weight height;

  class sex;

    types sex ();

    ods output Summary = temp_means;

  title "Sample statistics";

run; title;

data temp_means;

    set temp_means;

   if sex = " " then sex = "T";  *need to fill this in, we will need for transpose;

run;

proc transpose data = temp_means out = want;

id sex; *this will keep the value of your class variable as column names;

run;

good luck!

Anca.

View solution in original post


All Replies
Super Contributor
Posts: 333

Re: Proc Means: Getting the same information in both html and data set outputs

iank131,

Try adding the following types statement to the proc means code to add the total line to the html output:

...

class bindx_cat;

types bindx_cat ();

....

The () actually add the total line.

As far as requesting additional stats in the output... the only way I know is to request it on the output statement. Otherwise you get the default set of stats. If you want a vertical stack instead of horizontal listing you can transform it using transpose or data step.

Hope this helps


EJ

Contributor
Posts: 53

Re: Proc Means: Getting the same information in both html and data set outputs

Many thank EJ. That was very helpful!!

I knew it had to be that easy!

Ian.

Solution
‎01-28-2013 09:07 AM
Super Contributor
Posts: 543

Re: Proc Means: Getting the same information in both html and data set outputs

HI,

you could use and ODS OUTPUT statement instead of OUTPU, something like this (I also incorporate the nice 'types ..()' as suggested by EJ above.

(I am using sashelp.class as an example)

proc means data=sashelp.class n mean median stddev max min skew kurtosis prt;

  var age weight height;

  class sex;

    types sex ();

    ods output Summary = temp_means;

  title "Sample statistics";

run; title;

data temp_means;

    set temp_means;

   if sex = " " then sex = "T";  *need to fill this in, we will need for transpose;

run;

proc transpose data = temp_means out = want;

id sex; *this will keep the value of your class variable as column names;

run;

good luck!

Anca.

Contributor
Posts: 53

Re: Proc Means: Getting the same information in both html and data set outputs

Thanks so much Anca!!

Now I can get both html and the data set with the same information.

Ian.

Super Contributor
Posts: 333

Re: Proc Means: Getting the same information in both html and data set outputs

Great suggestion ODS OUTPUT ... I use it all the time dont know why I didnt think about that.

EJ

Grand Advisor
Posts: 16,889

Re: Proc Means: Getting the same information in both html and data set outputs

If you have SAS 9.3 and above check out the STACKODS option in proc means Smiley Happy

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 173 views
  • 3 likes
  • 4 in conversation