BookmarkSubscribeRSS Feed
frankielaporte
Calcite | Level 5

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;

3 REPLIES 3
Reeza
Super User

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.

Ksharp
Super User

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;


frankielaporte
Calcite | Level 5

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.

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

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
  • 3 replies
  • 3652 views
  • 0 likes
  • 3 in conversation