BookmarkSubscribeRSS Feed
Reader587
Calcite | Level 5

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. 

7 REPLIES 7
Reader587
Calcite | Level 5

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.

 

PaigeMiller
Diamond | Level 26

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?

--
Paige Miller
Tom
Super User Tom
Super User

@Reader587 wrote:

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 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.

LinusH
Tourmaline | Level 20
Apart from defining "real time" (like in predicted execution time for the step?), could you describe your requirement, why do you want this logic?
To be able to understand if your where clause will be true for any records you need to look into the data somehow. If you can't execute your SGPLOT, but ok to run a simple data _null_ step with the same where clause, you can test that outcome and then decide to run the next step by using macro logic, or issue an ENDSAS statement if that's more appropriate,
Data never sleeps
ballardw
Super User

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.

Astounding
PROC Star

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.

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1399 views
  • 1 like
  • 7 in conversation