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

Do any one know how to select columns to symmary inside PROC REPORT. I used 'RBREAK /AFTER'. It summarized all numerical variables. I want to summarize only the ones I need to. Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  Look in the doc at the difference between the default usage of SUM for numeric variables and the usage of DISPLAY. If you do not have DEFINE statements for your numeric variables, you will need to use a DEFINE statement so you can explicitly give a usage of DISPLAY -- this will turn off summarizing of the values at the RBREAK/BREAK. Something like:

DEFINE numvar / DISPLAY;

Without a DEFINE statement, ALL your numeric (analysis) variables have a default usage of SUM.

cynthia

View solution in original post

5 REPLIES 5
Cynthia_sas
SAS Super FREQ

Hi:

  Look in the doc at the difference between the default usage of SUM for numeric variables and the usage of DISPLAY. If you do not have DEFINE statements for your numeric variables, you will need to use a DEFINE statement so you can explicitly give a usage of DISPLAY -- this will turn off summarizing of the values at the RBREAK/BREAK. Something like:

DEFINE numvar / DISPLAY;

Without a DEFINE statement, ALL your numeric (analysis) variables have a default usage of SUM.

cynthia

qian
Calcite | Level 5

Thank you very much! Cynthia: It works! Is there any way I can fill in the 1st column in this row with "TOTAL"? AND re-calculate the values in other column in this summary row?

Cynthia_sas
SAS Super FREQ

Hi:

  I'm not sure what you mean by "re-calculate the values in other columns" ... what other columns? Why not let PROC REPORT do the calculation. For example, if you want to show the MEAN at the break, you can give your variable a usage that is the statistic you want to see at the break:

DEFINE SALARY / MEAN;

or

DEFINE SALARY / N;

The first DEFINE would show the average of all salaries at the RBREAK and the second DEFINE would show the COUNT (or N).

  But to get the word "Total" at the break, you would use a COMPUTE block. Something like:

COMPUTE AFTER;

  firstvar = 'TOTAL';

ENDCOMP:

cynthia

qian
Calcite | Level 5

Thank you again! Cynthia: For the 'TOTAL' thing, I used the COMPUTE block, no error, but for some reason it did not show up in the report. Do I need to put more infor somewhere to make it show up? For the 're-calculate', I need to compute the ratio from other two summaries and put it in this summary line under another column. Is that possible? Thank you so much for your help!

Cynthia_sas
SAS Super FREQ

Hi:

  For the 'TOTAL' thing, I can't even begin to guess what's going on, since you did not share your code (or any code). Possibly the variable in your first column is numeric or possibly the first variable is character, but has a length of 1...when you use the COMPUTE block technique, you are limited to the number of characters that represent the length of the item in the first column.

  So, if for some reason, you can't post your code and data, try to replicate your PROC REPORT using SASHELP.CLASS or SASHELP.SHOES. If the 'TOTAL' thing works with SASHELP.CLASS or SASHELP.SHOES, then you have to consider the differences between the SASHELP data and your data. IF the 'TOTAL' thing doesn't work with SASHELP datasets, then perhaps you have discovered something strange going on. But, again, seeing your code (your actual code and ALL your code, including ODS statements) will be most helpful.

  Have you read the PROC REPORT documentation? Or looked for user group papers about PROC REPORT and/or COMPUTE blocks? If you are new to PROC REPORT and COMPUTE blocks, perhaps some research would help focus your question or reveal where your COMPUTE block might be failing.

cynthia

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 5 replies
  • 1600 views
  • 0 likes
  • 2 in conversation