BookmarkSubscribeRSS Feed
silasskovsbo
Calcite | Level 5

Hello everybody. I have a problem.

I have a dataset with some variables including the variable YEAR. I want to make some descr. statistics on the other variables for each year.

I use proc means with class YEAR and it works fine but there is a problem. I want to have descr. statistics on all the relevant variables in one PDF but with tables showing the statistics for each variable - so one table for each variable.

I have tried this (see below) but it just makes one table with both variables.

proc means data=XXXXX;

     class YEAR ;

     var AGE EXPERIENCE ;

run;

Do somebody know how to make this with indivudal tables for each variable??

Thank you! Smiley Happy

Best // Silas, Aarhus University, Institute of Economics

6 REPLIES 6
Tom
Super User Tom
Super User

Do you just want to run two proc means?

proc means data=xxxx;

  class year;

  var age ;

run;

proc means data=xxxx;

class year;

var experience;

run;

If more than a hand full then you could do it with a macro.

silasskovsbo
Calcite | Level 5

I am also ended with that solution now but since there are many variables and very big data set it is a very demanding procedure.

I wondered if there was a solution like when you work with proc freq you can have more variables in one print by this simple code.

proc freq data=XXXX;

tables YEAR*(AGE EXPERIENCE);

run;

And thanks!

Tom
Super User Tom
Super User

Why not just have PROC MEANS output a dataset and the use PRINT or REPORT to display it the way you want?

asishgautam
Calcite | Level 5

Have you looked into "by group" processing?  Note that this will require sorting your data set by the "by groups".

proc means data=XXXXX;

     by YEAR ;

     var AGE EXPERIENCE ;

run;

ballardw
Super User

One approach is to reshape your data.

data want (keep year  var value);

     set have;

     array vars (list of your analysis variables);

    length variable $32;

     do i = dim(vars);

          call vname( vars,variable);

          value = vars;

          output;

     end;

run;

This creates a data set with year, the name of the variable as the value of a string variable and the value.

Then sandwich the below code in appropriate ODS PDF or RTF call. Defaults to one table per page.

proc tabulate data=want;

     class variable year;

     var value;

     table variable,  /* as first item this will be table level*/

              value *(n mean max min std),  /* or which ever statistics you want these will be row variables)

               year ; /* year would be column variable, if you want year as the row, then reverse the order of these*/

run;


silasskovsbo
Calcite | Level 5

Thank you for the help, everybody! I have now found a satisfying solution.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 2163 views
  • 4 likes
  • 4 in conversation