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;
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.
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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.