BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
meenakshim
Fluorite | Level 6

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,

 

meenakshim_0-1617758458925.png

 

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,

meenakshim_1-1617758521190.png

 

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)

 

meenakshim_2-1617758634782.png

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)

 

meenakshim_3-1617758880044.png

 

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? 

 

meenakshim_2-1617758634782.png

1 ACCEPTED SOLUTION

Accepted Solutions
2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

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

 

ChrisNZ
Tourmaline | Level 20

All will work if you change to compute CNT;

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1155 views
  • 0 likes
  • 2 in conversation