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

Hi,

I have a problem with my proc report in the call define part.I'm not going to use my real data, I'm trying to use the class table instead. I want to make two conditions on my call define,If I only use the first condition: if weight = 77 I have no problem. but if I add the second condition I have nothing in the result. I think I have a problem with my code.

Thank's

proc report data=sashelp.class;
    
    column age name sex height weight;
	define name / order;
	define age / order;
	define sex / display;
	define height /analysis;
	define weight / display;
	compute weight;
	  if weight >95 and height>63 then do;
	    
		call define('height.sum','style','style={background=lightgreen}');
		
	  end;
	endcomp;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

I am not seeing a description of what you want to actually accomplish.

 

Generally Proc Report builds things from left to right. So values of weight, which appear to the RIGHT of Height in your table are already "past" building values for height.

 

Perhaps:

proc report data=sashelp.class;
    
   column age name sex weight Height ;
	define name / order;
	define age / order;
	define sex / display;
	define Height /analysis sum;
	define weight / display;
	compute height;
	  if weight >95 and height.sum>63 then do;
		call define('Height.sum','style','style={background=lightgreen}');
		
	  end;
	endcomp;
run;

View solution in original post

9 REPLIES 9
maguiremq
SAS Super FREQ

I haven't used it in this way, but this gives you the green boxes for SASHELP.CLASS.

 

proc report data=sashelp.class;
    
    column age name sex height weight;
	define name / order;
	define age / order;
	define sex / display;
	define height / display;
	define weight / display;
	compute weight;
	  if weight >95 and height>63 then do;
	    
		call define('height','style','style={background=lightgreen}');
		
	  end;
	endcomp;
run;

Changed height from analysis to display, and removed the .sum in the call define.

maguiremq_0-1697047111301.png

 

Again, not sure if that's what you need.

snip
Obsidian | Level 7

did you read my message?

I have to keep define height in analysis and define weight in display

and that's not what you used

maguiremq
SAS Super FREQ
Ah, my apologies.
snip
Obsidian | Level 7

I think I'm misdeclaring the call define...

could someone help me please?

 

PaigeMiller
Diamond | Level 26

Why do you feel that HEIGHT should be an analysis variable? For this example, there is no benefit to make HEIGHT an analysis variable.

--
Paige Miller
ballardw
Super User

@PaigeMiller 

OP is using SASHELP.Class as a surrogate for his actual data and  just needed something to sum.

PaigeMiller
Diamond | Level 26

That may be the case, but then the responsibility is on the OP to find an example data set that illustrates the problem, and not show us a data set that is different in important ways and does not illustrate the problem.

--
Paige Miller
ballardw
Super User

I am not seeing a description of what you want to actually accomplish.

 

Generally Proc Report builds things from left to right. So values of weight, which appear to the RIGHT of Height in your table are already "past" building values for height.

 

Perhaps:

proc report data=sashelp.class;
    
   column age name sex weight Height ;
	define name / order;
	define age / order;
	define sex / display;
	define Height /analysis sum;
	define weight / display;
	compute height;
	  if weight >95 and height.sum>63 then do;
		call define('Height.sum','style','style={background=lightgreen}');
		
	  end;
	endcomp;
run;
snip
Obsidian | Level 7

I used the class table only to give an example and show you my problem.I made sure to reproduce my problem on the class table, I know that there is no sense in applying it to this table but I do not have the possibility of sharing my real data. @ballardw was able to answer me, your code syntax suits me very well and that's what I was looking for.

THANKS 

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
  • 9 replies
  • 880 views
  • 1 like
  • 4 in conversation