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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.