BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DavidPhillips2
Rhodochrosite | Level 12

I noticed that a script that runs on our server displays the total time to complete a SAS script.  When I run SAS programs on my local machine I only see the real time and CPU time for each step.  How can I view the full time?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
%let start= %sysfunc(datetime());


data a;
 set sashelp.class;
 id=1;
run;
data b;
 set sashelp.air;
 id=1;
run;






proc contents data=work._all_ out=temp varnum noprint;
run;
proc sql noprint;
select  name into : list separated by ' '
 from temp
  group by name
   having count(*)>1;

create table want as
select  distinct memname
 from temp
  group by name
   having count(*)>1;
quit;
data _null_;
 set want end=last;
 if _n_=1 then call execute('proc datasets library=work nolist nodetails; ');
 call execute(cat('modify ',memname,';'));
 call execute(cat('drop ',"&list",';'));
 if last then call execute(';quit;');
run;


%let end=%sysfunc(datetime());
%let duration=%sysfunc(putn(%sysevalf(&end-&start),time.));

%put  timecost &duration.

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

The real and CPU time of a SAS batch script is actually the SAS session time for that script to run as it runs in its own dedicated session.

 

In EG there is no equivalent. A single script in EG doesn't run in its own session, it runs in an EG session where many projects or scripts could be run. While it is easy to calculate the real time of a SAS script run in EG using the SAS TIME() function, there is no easy way to capture total CPU time for a single script that I am aware of. Parsing the SAS log is always an option but I'm not sure the effort involved is worth it. Running the script in batch is a whole lot easier.

Ksharp
Super User
%let start= %sysfunc(datetime());


data a;
 set sashelp.class;
 id=1;
run;
data b;
 set sashelp.air;
 id=1;
run;






proc contents data=work._all_ out=temp varnum noprint;
run;
proc sql noprint;
select  name into : list separated by ' '
 from temp
  group by name
   having count(*)>1;

create table want as
select  distinct memname
 from temp
  group by name
   having count(*)>1;
quit;
data _null_;
 set want end=last;
 if _n_=1 then call execute('proc datasets library=work nolist nodetails; ');
 call execute(cat('modify ',memname,';'));
 call execute(cat('drop ',"&list",';'));
 if last then call execute(';quit;');
run;


%let end=%sysfunc(datetime());
%let duration=%sysfunc(putn(%sysevalf(&end-&start),time.));

%put  timecost &duration.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 2 replies
  • 5176 views
  • 2 likes
  • 3 in conversation