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.

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore 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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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