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;
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: