Hi,
Below is my simple report to export dataset to excel and highlight a row if it has value as null for a particular record,
Dataset used has following records,
ods results on ;ods excel file="C:\Data\GENDER.xlsx"
options (sheet_interval='none' embedded_titles = 'yes' SHEET_NAME="PROVTYPE_ERR" );
proc report data = UNIQUEPROVIDERTYPES ;
column FIELD_NAME VALUE cnt ;
define field_name/display;
define value/display;
define cnt/display ;
compute value;
if value = ' ' then do ;
call define ('field_name','style','style = {background=red}');
call define ('value','style','style = {background=red}');
call define ('cnt','style','style = {background=red}');
end;
endcomp;
run;
Case 1: When i run above program , i get report as below without highlighting CNT column,
Case 2: When i replace multiple define statements into one as below ,
call define (_row_,'style','style = {background=red}');
My report looks like below (Highlighting the CNT last column as well)
Case 3: when i replace only my column statement as below , bringing CNT variable in the front (not as last variable)
column FIELD_NAME cnt VALUE ;
My report looks like below (Highlighting the CNT but this time it is not the last column because of order changed in column statement)
My doubt is why i am not getting the required results as below during the case 1 scenario.
Why CNT variable as last column is not highlighted in case1? Why order changing in column statement in case 3 highlight the column CNT good?
All will work if you change to compute CNT;
Proc report cannot see upcoming columns in compute column block, only columns already processed.
Also:
1. Use SASHELP data for this type of example so we can replicate easily
2. Paste your code using the appropriate icon
All will work if you change to compute CNT;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.