The SAS Output Delivery System and reporting techniques

Repeating values of group variables in proc report

Reply
New Contributor
Posts: 2

Repeating values of group variables in proc report

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;

Grand Advisor
Posts: 16,263

Re: Repeating values of group variables in proc report

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.

Grand Advisor
Posts: 9,307

Re: Repeating values of group variables in proc report


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;


New Contributor
Posts: 2

Re: Repeating values of group variables in proc report

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.

 

 

Post a Question
Discussion Stats
  • 3 replies
  • 535 views
  • 0 likes
  • 3 in conversation