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;
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;
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.
Again, not sure if that's what you need.
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
I think I'm misdeclaring the call define...
could someone help me please?
Why do you feel that HEIGHT should be an analysis variable? For this example, there is no benefit to make HEIGHT an analysis variable.
OP is using SASHELP.Class as a surrogate for his actual data and just needed something to sum.
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.
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;
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
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.