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
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;
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;
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.
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.