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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 425 views
  • 1 like
  • 2 in conversation