Hey all,
Is there a way to make SAS run only when real time is greater than 0?
The reason I am asking is because I wrote a macro and it executes.
For example,
" proc sgplot data=sashelp.cars;
vbar type/dataskin=pressed;
where make="BMW" and cylinders=3;
run; "
won't run because when make=BMW, cylinders is never equal to 3.
I want SAS to execute only when the where clause is true or when real time is greater than 0.
Thank You.
Hey Kurt,
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
You know how there's always a real time and cpu time in the log. I presented an example above.
Thanks.
I'm misunderstanding something here. What does real-time gt 0 when running PROC CONTENTS have to do with the case where BMWs don't have 3 cylinders?
@Reader587 wrote:
Hey Kurt,
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.01 seconds
cpu time 0.01 secondsYou know how there's always a real time and cpu time in the log. I presented an example above.
Thanks.
I don't know of any way to retrieve that information. But if you need to know how long a step takes then you can remember when it starts and then calculate how long it took.
%let startdt = %sysfunc(datetime());
proc contents;
run;
%let duration=%sysevalf(&startdt - %sysfunc(datetime()));
What that has to do with PROC SGPLOT or WHERE statements I have not idea.
Why are you creating a WHERE with invalid data to begin with? That points to a very serious design flaw on your part.
Look at how you generate the where and fix that.
It appears that you are trying to create the plot whenever the WHERE statement actually pulls observations. If so, here's a way to do that:
data _null_;
set sashelp.cars;
where make="BMW" and cylinders=3;
call execute
('proc sgplot data=sashelp.cars;
vbar type/dataskin=pressed;
where make="BMW" and cylinders=3;
run;'
);
stop;
run;
There are other mildly similar ways to go about this as well. If any observations meet the WHERE condition, the DATA step generates a PROC SGPLOT. If no observations meet the WHERE condition, the DATA step generates nothing. Either way, the DATA step ends.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.