BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
nitink26
Obsidian | Level 7

Hi,

Code - 


%macro aa;
%do I = 1 %to 4;
PROC SQL NOPRINT ;
SELECT ID INTO : ITEM FROM TEST
WHERE N = &I.;
QUIT;

PROC SQL NOPRINT ;
SELECT VALUES INTO : other_items FROM TEST
WHERE N = &I.;
QUIT;

%PUT &ITEM. &other_items.;
proc report data=TEST;
column ID A1-A7 VALUES;


compute A1;
IF ID = &item. and A1 IN &other_items.
THEN call define('A1', "style", "style=[background=lightgreen]");
endcomp;

compute A2;
IF ID = &item. and A2 IN &other_items.
then call define('A2', "style", "style=[background=lightgreen]");
endcomp;

compute A3;
IF ID = &item. and A3 IN &other_items.
then call define('A3', "style", "style=[background=lightgreen]");
endcomp;

compute A4;
IF ID = &item. and A4 IN &other_items.
then call define('A4', "style", "style=[background=lightgreen]");
endcomp;

compute A5;
IF ID = &item. and A5 IN &other_items.
then call define('A5', "style", "style=[background=lightgreen]");
endcomp;

compute A6;
IF ID = &item. and A6 IN &other_items.
then call define('A6', "style", "style=[background=lightgreen]");
endcomp;

compute A7;
IF ID = &item. and A7 IN &other_items.
then call define('A7', "style", "style=[background=lightgreen]");
endcomp;
%END;
%mend;
%AA;

run;

 

output from above code- 

nitink26_0-1677405347982.png

 

Output I need -

nitink26_1-1677405526932.png

 

I need output on the basis of id and VALUES column and highlight the cells A1-A7 according to values in column VALUES. 

Here ID is a unique identifier and one ID has only one unique value in VALUES column.

 

Dataset test is attached for your reference.

 

 

 

1 ACCEPTED SOLUTION
2 REPLIES 2

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 980 views
  • 1 like
  • 2 in conversation