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;
proc report nowd data=example;
col type color season,cost;
define type / group;
define color / group;
define season / across ' ';
define cost / ' ';
run;
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
@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...
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.
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;
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).
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.
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
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
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!
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.