Hi,
I will like to bold the following sub-heading (Sex, Age category, Race/Ethnicity) and also remove the periods (.) each row in my proc report code. I have made multiple attempt but am not getting it. Please see my code below. Thanks in advance.
proc report data=case
style(report)=[background=white]
style(header)=[background=#919CB2 foreground=black borderstyle=hidden];
col Cat2 Y2020 Y2021 Y2022 Y2023 Y2024 Total;
define cat2/display 'Variable';
/*Make row headings bold and more readable*/
compute cat2;
if cat2 in('Sex' 'Age category' 'Race/Ethnicity' ) then do;
call define(_row_, "style", "style=[backgroundcolor=#DFE5E5 fontweight=bold]");
end;
endcomp;
/*Make the . disappear in the row headings*/
compute count;
if cat2 in('Sex' 'Age category' 'Race/Ethnicity') then do;
call define(_col_, "style", "style=[foreground=#DFE5E5]");
end;
endcomp;
run;
The subheadings are bold for me with sample data. Make sure that the Cat2 values in the Compute block match the actual data values. You can also try this:
compute cat2;
if strip(cat2) in('Sex' 'Age category' 'Race/Ethnicity' ) then do;
call define(_row_, "style", "style=[backgroundcolor=#DFE5E5 fontweight=bold]");
end;
endcomp;
If you continue to have problems, can you send your log and/or actual data?
Count is not a variable in the PROC REPORT definition. If I run your code with sample data without the Compute block for Count, those headings are bold.
Here is the revised code:
options missing=' ';
proc report data=case
style(report)=[background=white]
style(header)=[background=#919CB2 foreground=black borderstyle=hidden];
col Cat2 Y2020 Y2021 Y2022 Y2023 Y2024 Total;
define cat2/display 'Variable';
/*Make row headings bold and more readable*/
compute cat2;
if cat2 in('Sex' 'Age category' 'Race/Ethnicity' ) then do;
call define(_row_, "style", "style=[backgroundcolor=#DFE5E5 fontweight=bold]");
end;
endcomp;
/*Make the . disappear in the row headings*/
/*compute count;*/
/*if cat2 in('Sex' 'Age category' 'Race/Ethnicity') then do;*/
/*call define(_col_, "style", "style=[foreground=#DFE5E5]");*/
/*end;*/
/*endcomp;*/
run;
Which ODS destination are you using? Can you include a sample of the output?
@Kathryn_SAS Yes, the heading (Variable, Y2020-Y2024, Total) are bold but i want to make ('Sex' 'Age category' 'Race/Ethnicity') bold too. I am using ods excel as destination. The snippet I posted was my output. The options missing=' '; has removed the (.) Now I want the SUB-heading; sex, age category and race/ethnicity to be bold. Thanks
ods excel file="Req/health_result.xlsx"
options(embedded_titles='yes' sheet_interval='NONE' sheet_name='Telehealth')
The subheadings are bold for me with sample data. Make sure that the Cat2 values in the Compute block match the actual data values. You can also try this:
compute cat2;
if strip(cat2) in('Sex' 'Age category' 'Race/Ethnicity' ) then do;
call define(_row_, "style", "style=[backgroundcolor=#DFE5E5 fontweight=bold]");
end;
endcomp;
If you continue to have problems, can you send your log and/or actual data?
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.