BookmarkSubscribeRSS Feed
SAS_new
Calcite | Level 5

Hi-

I have the following code that produces the Report I need.  What I am having difficulty with is the summarize row.  I would like to rename it to SchoolCode Total but it will not allow me.  Is there anyway to do this?

PROC REPORT NOWD DATA=Q1 OUT=Q1A

NOFS HEADLINE HEADSKIP;

COLUMNS SCHOOLcODE RACE FCODE TOTAL;

DEFINE SCHOOLCODE / GROUP;

DEFINE RACE / DISPLAY;

DEFINE FCODE / DISPLAY;

DEFINE TOTAL/ ANALYSIS SUM;

BREAK AFTER SCHOOLCODE / SUMMARIZE  ;

RUN;


4 REPLIES 4
Cynthia_sas
Diamond | Level 26

Hi:

  Just curious, why are you creating an OUTPUT dataset? Do you need this output in another step?

  At any rate, you will need a COMPUTE block to do what you want. I believe there have been other postings. I am not in a position to make up dummy data right now. But one possibility is (untested code snippet):

compute after schoolcode;

  schoolcode = 'Total';

endcomp;

Assuming that SCHOOLCODE is "big enough" (at least 5 characters in length), you should get what you want. Other desires, such as getting Total for XXX, requre a bit more work, but are also do-able.

cynthia

SAS_new
Calcite | Level 5

Thank you Cynthia- 

SAS_new
Calcite | Level 5

Cynthia-

How would I enter another compute after race in addition to schoolcode?

compute after schoolcode;

  schoolcode = 'Total';

endcomp;

Cynthia_sas
Diamond | Level 26

Hi:

  You show RACE in your original code sample as a DISPLAY variable. As long as RACE is DISPLAY usage, you cannot do a COMPUTE AFTER. The only variables that can have COMPUTE AFTER (or BEFORE) are ORDER or GROUP variables. So, you could define RACE as either ORDER or GROUP and then you would be able to do a COMPUTE AFTER, pretty much, the code would look the same as what is shown above, except where you have SCHOOLCODE, you would now put RACE.

  Also, depending on what you were going to COMPUTE and the length (number of characters) for the RACE variable, you may or may not be able to assign the string TOTAL to the RACE column (for example, if RACE was a code of 1,2 or 3), then you could not assign TOTAL at the break. But you could make a computed column to hold a longer name.

  This documentation topic of how PROC REPORT builds a report is quite helpful:

Base SAS(R) 9.3 Procedures Guide, Second Edition

  In addition, I know that there are previous forum postings on break processing using PROC REPORT, with code examples. Here is a previous posting from this year: https://communities.sas.com/message/150671#150671 I am sure there are others.

cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 1616 views
  • 1 like
  • 2 in conversation