I'm getting an expected result when I run the following code. The first three (non-hidden) columns are group variables so I was expecting the output to only print the first value of the group variable on the first row of the report. However, it's repeating the value for all of the rows (i.e., "age at first service" is on rows 1-5 instead of just row 1). Notice, the first three (hidden) columns are being used just to order the data in the output and create sub groups.
Proc print and sample report attached here. Note, I removed the actual data (statistics) for proprietary reasons. Thanks.
proc report data=supp.d12a_supp nowd missing out=outtest;
column cat_order grp_order grp_order2 cat_char grp_char grp_char2 last_mod,stat;
define cat_order / group order=data noprint;
define grp_order / group order=data noprint;
define grp_order2 / group order=data noprint;
define cat_char / group "" format=$60. left;
define grp_char / group "" format=$25. left;
define grp_char2 / group "" format=$25. left;
define last_mod / group across "" order=data format=$20. Center style(header)={Just=C};
define stat / "" sum format=DecimalFmt. style(column)=[tagattr="format:%quote(#,##0.0)"] right;
run;
What version of SAS and tagsets are you using?
Run Proc SETINIT for SAS version and for tagset version it should be in your log after your run the code above, just below the ODS open statement.
Also, can you replicate the issue with a dataset that we can work with, one in SASHELP would be ideal.
You don't need these NOPRINT variable ,just need ORDER=DATA. proc import datafile='/folders/myfolders/procprint.xlsx' out=have dbms=xlsx replace;run; data have; set have; if mod(_n_,2)=1 then last_mod='Y'; else last_mod='N'; retain stat 1; run; proc report data=have nowd missing out=outtest ; column cat_char grp_char grp_char2 last_mod,stat; define cat_char / group "" format=$60. left order=data; define grp_char / group "" format=$25. left order=data; define grp_char2 / group "" format=$25. left order=data; define last_mod / group across "" order=data format=$20. Center style(header)={Just=C}; define stat / "" sum format=DecimalFmt. style(column)=[tagattr="format:%quote(#,##0.0)"] right; run;
All, thanks for the comments, but I figured it out on my own. I had to re-order the variables in the define statement. Now it works as expected.
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 how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.