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

Hi All..

I having small prob with Compute block in proc report..

here is the my sample code.

proc report data=sasuser.admit;

column age fee height;

define age/display;

define fee/"Max Fee";

define Height/"Max Height";

rbreak after/summarize dul dol;

compute after;

if _BREAK_= "_RBREAK_"  then

age="Total";

endcomp;

run;

here i am trying to get the total value for  Fee and height variables and i want to display "Total" text in the bottom of the Age variable.

but the problem is age is a a numeric variable,so i can not insert the text in  that variable..

anybody have any suggestion  for this???

Thanks in Advance..

Regards..

Sanjeev.K

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26


Hi:

  As you have discovered, a usage of DISPLAY doesn't change the fundamental nature of the underlying variable. AGE was still numeric, so you couldn't assign a text string to the value at the break point.

  There are several different ways to get what you want. Probably the simplest is to either

1) create a computed item on the report from AGE or 2) create a character version of AGE in a WORK dataset before the REPORT step. You seem to be using the LISTING output (since you show DOL and DUL), so an ODS method (using PRETEXT) won't work for you.

  A simple example using SASHELP.CLASS is shown below.

cynthia

proc report data=sashelp.class nowd;

  column age showage name height;

  define age/display noprint;

  define showage / computed "Age" right;

  define name/"Name";

  define Height/"Height";

  rbreak after/summarize dul dol;

  compute showage / character length=5;

     showage = put(age,2.0);

     if _BREAK_ = "_RBREAK_" then

        showage = 'Total';

  endcomp;

run;

View solution in original post

1 REPLY 1
Cynthia_sas
Diamond | Level 26


Hi:

  As you have discovered, a usage of DISPLAY doesn't change the fundamental nature of the underlying variable. AGE was still numeric, so you couldn't assign a text string to the value at the break point.

  There are several different ways to get what you want. Probably the simplest is to either

1) create a computed item on the report from AGE or 2) create a character version of AGE in a WORK dataset before the REPORT step. You seem to be using the LISTING output (since you show DOL and DUL), so an ODS method (using PRETEXT) won't work for you.

  A simple example using SASHELP.CLASS is shown below.

cynthia

proc report data=sashelp.class nowd;

  column age showage name height;

  define age/display noprint;

  define showage / computed "Age" right;

  define name/"Name";

  define Height/"Height";

  rbreak after/summarize dul dol;

  compute showage / character length=5;

     showage = put(age,2.0);

     if _BREAK_ = "_RBREAK_" then

        showage = 'Total';

  endcomp;

run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1 reply
  • 953 views
  • 0 likes
  • 2 in conversation