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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 7 replies
  • 810 views
  • 1 like
  • 7 in conversation