BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
iank131
Quartz | Level 8

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!!

1 ACCEPTED SOLUTION

Accepted Solutions
AncaTilea
Pyrite | Level 9

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

6 REPLIES 6
esjackso
Quartz | Level 8

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

iank131
Quartz | Level 8

Many thank EJ. That was very helpful!!

I knew it had to be that easy!

Ian.

AncaTilea
Pyrite | Level 9

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.

iank131
Quartz | Level 8

Thanks so much Anca!!

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

Ian.

esjackso
Quartz | Level 8

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

EJ

Reeza
Super User

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

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