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

Hi All,

 

I am writing a program in SAS, and using Proc means data=some name to display the output in pdf report.

I am renaming the variables with label statement. One label name is quite long and at the time of getting printed in pdf it is being displayed in 2 lines rather than 1.

 

Need this way: 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You "picture" in the attachment showed no details of what the "report" might actually look like so can't provide a better targeted example.

Here is an example of using Proc Tabulate to display some statistics and controlling the width of the area the labels appear in.

Proc tabulate data=sashelp.class;
   class sex;
   classlev sex/ style=[width=1.5in];
   label sex='Student Sex';
   var height;
   table sex,
         height='Student Height'*{style=[width=3in]}*(mean  min max stddev)
   ;
run;

You should have the SASHELP.Class data set available and can run this code.

This demonstrates two different types of labels for Class (grouping variables) and Var (analysis variables).

The Classlev statement overrides the default (i.e. the procedure generic code) for setting the width of the column that the variable Sex label and values appear in. In this case I set that 1.5 inches. The example for height shows using table options to 1) override the default Label in line without use of a label statement and 2) how to override the width, setting it to 3 inches in this case to make it fairly obvious that we can set widths much longer than actually needed.

 

Proc Tabulate pretty much does all the statistics that Proc Means/Summary does as well as some percentages.

You can also "nest" in multiple dimensions and request multiple different tables in one procedure call. Tradeoffs: you have to explicitly state a variable is either a Class or Var variable and only those are used in the table(s). Any observation with a missing value for one or more of the class variables is excluded from the summary.

 

 

View solution in original post

2 REPLIES 2
Reeza
Super User
You don't have control when you use PROC MEANS and the default procs.

Pipe your results to a table and then use PROC REPORT or PRINT to display them cleanly. You may also have more control in PROC TABULATE.
ballardw
Super User

You "picture" in the attachment showed no details of what the "report" might actually look like so can't provide a better targeted example.

Here is an example of using Proc Tabulate to display some statistics and controlling the width of the area the labels appear in.

Proc tabulate data=sashelp.class;
   class sex;
   classlev sex/ style=[width=1.5in];
   label sex='Student Sex';
   var height;
   table sex,
         height='Student Height'*{style=[width=3in]}*(mean  min max stddev)
   ;
run;

You should have the SASHELP.Class data set available and can run this code.

This demonstrates two different types of labels for Class (grouping variables) and Var (analysis variables).

The Classlev statement overrides the default (i.e. the procedure generic code) for setting the width of the column that the variable Sex label and values appear in. In this case I set that 1.5 inches. The example for height shows using table options to 1) override the default Label in line without use of a label statement and 2) how to override the width, setting it to 3 inches in this case to make it fairly obvious that we can set widths much longer than actually needed.

 

Proc Tabulate pretty much does all the statistics that Proc Means/Summary does as well as some percentages.

You can also "nest" in multiple dimensions and request multiple different tables in one procedure call. Tradeoffs: you have to explicitly state a variable is either a Class or Var variable and only those are used in the table(s). Any observation with a missing value for one or more of the class variables is excluded from the summary.

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 788 views
  • 0 likes
  • 3 in conversation