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
SAS Super FREQ


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
SAS Super FREQ


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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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