Help using Base SAS procedures

Problem With Proc Report

Accepted Solution Solved
Reply
Super Contributor
Posts: 276
Accepted Solution

Problem With Proc Report

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


Accepted Solutions
Solution
‎08-24-2012 10:15 AM
SAS Super FREQ
Posts: 8,868

Re: Problem With Proc Report

Posted in reply to kuridisanjeev


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


All Replies
Solution
‎08-24-2012 10:15 AM
SAS Super FREQ
Posts: 8,868

Re: Problem With Proc Report

Posted in reply to kuridisanjeev


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;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 175 views
  • 0 likes
  • 2 in conversation