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