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

Hi guys... I am trying to use multiple condition in compute block in proc report, however I am unable to produce expected output. Anyone can plz help below is the sample code..

proc report data=sashelp.class nowd;
columns _All_;
define _All_/ display;

compute Name;
if Age > 15 and Height >69 then do;
call define(_row_, 'style', 'style={foreground=Red background=Yellow fontweight=bold}');
end;
endcomp;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Use

 

compute weight;

 

instead of

 

compute name;

 

Why? Because in a compute block in PROC REPORT, you can only use variable names that are the variable named in the compute block and variables in the COLUMNS statement to the left of that variable. It cannot use variables named in the COLUMNS statement to the right of that variable. When you use compute name; it can use NAME and variables to the left of name in the COLUMNS statement (and there are none); when you use compute weight; it can use all the variables because every other variable is to the left of weight.

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Use

 

compute weight;

 

instead of

 

compute name;

 

Why? Because in a compute block in PROC REPORT, you can only use variable names that are the variable named in the compute block and variables in the COLUMNS statement to the left of that variable. It cannot use variables named in the COLUMNS statement to the right of that variable. When you use compute name; it can use NAME and variables to the left of name in the COLUMNS statement (and there are none); when you use compute weight; it can use all the variables because every other variable is to the left of weight.

--
Paige Miller
SatishR
Obsidian | Level 7

Thanks @Paige Miller.
It is working and my concern also resolved.

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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