BookmarkSubscribeRSS Feed
ss171
Calcite | Level 5

I have pasted a small sample data for reference and the expected output . If anyone can help in customizing the proc report output. Let me know if this can be done by changing proc report options in the existing code  

data example;
input Type $ Color $ Season $ Cost;
cards;
flower purple winter 1000
flower pink spring 2000
flower pink winter 1500
;
run;

proc report nowd data=example;
col type color season,cost;
 define type / display;
 define color / display;
 define season / across ' ';
 define cost / ' ';
run;

ss171_0-1628079452887.png

 

12 REPLIES 12
PaigeMiller
Diamond | Level 26
proc report nowd data=example;
col type color season,cost;
 define type / group;
 define color / group;
 define season / across ' ';
 define cost / ' ';
run;
--
Paige Miller
ss171
Calcite | Level 5

Thanks , Changing to group for type and color will not print the type for all as "flower" but I want it to be populated in the final report

PaigeMiller
Diamond | Level 26

@ss171 wrote:

Thanks , Changing to group for type and color will not print the type for all as "flower" but I want it to be populated in the final report


The fix is given here: https://communities.sas.com/t5/SAS-Procedures/Repeat-group-variables-in-proc-report-containing-acros...

--
Paige Miller
andreas_lds
Jade | Level 19

Changing "display" to "group" in the define statements for "type" and "color" will get you closer to the expected result, unfortunately the table header still looks disgusting.

Kurt_Bremser
Super User

Use two variables as GROUP, and change the order in the COLUMN statement:

proc report data=example;
column type color cost,season;
define type / group;
define color / group;
define season / across ' ';
define cost / ' ';
run;
ss171
Calcite | Level 5
Changing it to group will not populated 'type' in the report for all , as this is just a sample data which I had pasted so this is fine but for the actual data and report , its needed to print in the report as the first column
Kurt_Bremser
Super User

Add a computed column that will always have the value:

proc report nowd data=example;
col type disp_type color cost,season;
define type / group noprint;
define disp_type / computed "Type";
define color / group;
define season / across ' ';
define cost / ' ';
compute before type;
  hold_type = type;
endcomp;
compute disp_type / character;
  disp_type = hold_type;
endcomp;
run;

Gleaned from a code by @Cynthia_sas found here: https://communities.sas.com/t5/ODS-and-Base-Reporting/proc-report-repeat-the-group-value-for-each-li..., which is the first result of a google search for "sas proc report print group value in every line" (see Maxim 6).

Cynthia_sas
SAS Super FREQ
Thanks @Kurt_Bremser! That's exactly how I hope folks will find some of my older posts. For more ins and outs with ACROSS items and PROC REPORT, this is my paper about using ACROSS items: https://support.sas.com/resources/papers/proceedings14/SAS388-2014.pdf

Cynthia
PaigeMiller
Diamond | Level 26

Thanks, @Cynthia_sas , I have bookmarked that link.

 

However, now that I'm watching the Olympic Track and Field competition, I think your title "Sailing Over ... Hurdles" is somewhat of a mixed metaphor ... 😊 , at least based on Olympic sports.

--
Paige Miller
Cynthia_sas
SAS Super FREQ
Yes, I am sports-challenged. But somehow, "Leaping Over the ACROSS Hurdle" didn't sound as triumphant as "Sailing Over"!
Cynthia
ss171
Calcite | Level 5

I used the below code to display total as well in the last row but the value is retained till there for type 

proc report nowd data=example;
col type disp_type color cost,season cost=tot;
define type / group noprint;
define disp_type / computed "Type";
define color / group;
define season / across ' ';
define cost / ' ';
define tot / analysis sum 'Total' format=comma32. style={tagattr='format:#,##0;-#,##0'} ;
      rbreak after / summarize style=[font_weight = bold] dul dol;
compute before type;
  hold_type = type;
endcomp;
compute disp_type / character;
  disp_type = hold_type;
endcomp;
 compute after;
color='Total';
endcomp; run;

but just want to remove the column1 i.e flower from the last row i.e. in the total row . Please guide if it can be happened 

ss171_0-1630043748136.png

 

Cynthia_sas
SAS Super FREQ

Hi:

  Just as you can assign a value in the COMPUTE block to get the word "Total" in the column for COLOR, you can change the value of DISP_TYPE to be either blank or something else (like All):

Cynthia_sas_0-1630093804004.png

 

Cynthia

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 12 replies
  • 1173 views
  • 2 likes
  • 5 in conversation