BookmarkSubscribeRSS Feed
azambvitor
Calcite | Level 5

Hi guys! 

I have a project that contains 2 programs linked one in each other and they work like this:

 

---> Program01: Have a lot of data steps, load some txt files and create the database0_1. 

---> Program02: Treat some variables and create another variables in the database0_2, from database0_1.

---> Export database0_2 as step in project.

 

I want to create some macro variables that reflect the time spent, so I can send those numbers by email during the project  while it is running. This is what I am doing

 

At begining of Program01:

 

%macro get_start();
	%global hr_start;
	%let hr_start= %sysfunc(datetime(), DATETIME18.);
/*Print in log the datetime*/ %put HOUR_START >>>>>>>>>>>>>>>>>>> &hr_start; %let hr_start= %sysfunc(datetime(), TIMEW.); %mend; %get_start;

Then, at the end of Program02 I created the code above:

 

 

%macro get_end();
	%global hr_end;
	%let hr_end = %sysfunc(datetime(), DATETIME18.);
	%put HOUR_END >>>>>>>>>>>>>>>>>>> &hr_end;
	%let hr_end = %sysfunc(datetime(), TIMEW.);
	%let time_elapsed = %sysfunc(intck(seconds,&hr_start,&hr_end));
	%put TIME ELAPSED >>>>>>>>>>>>>>>>>>>  &time_elapsed SECONDS;
%mend;

%get_end;

/*SEND EMAIL*/
options emailsys=smtp;

filename msg email 
	to=("vitor@mymail.com.br")
	from=("vitor@mymail.com.br")
	subject = "database0_2 updated at &hr_end";

data _null_;
	file msg;
	put "BEGIN OF PROCESS: &hr_start";
	put "END OF PROCESS: &hr_end";
	put " ";
	put "database0_2 updated with approximate time elapsed of &time_elapsed SECONDS";
run;

But in my email I receive the subject "database0_2 updated at 1954495693" and the message:

 

 

BEGIN OF PROCESS: &hr_start

END OF PROCESS: 1954495693

 

database0_2 updated with approximate time elapsed of &time_elapsed SECONDS

What I have to change so I can receive my subject as "database0_2 updated at 07DEC21:08:36:37"  and my message as below?

BEGIN OF PROCESS: 21:02:30:37

END OF PROCESS: 21:08:36:37

 

database0_2 updated with approximate time elapsed of 246 SECONDS

 

 

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

Something like this?

 

At beginning of Program01:

%put HOUR_START >>>>>>>>>>>>>>>>>>> %sysfunc(datetime(), DATETIME20.);
%let hr_start= %sysfunc(datetime());

Then, at the end of Program02:

%put HOUR_END >>>>>>>>>>>>>>>>>>>  %sysfunc(datetime(), DATETIME20.);
%let hr_end = %sysfunc(datetime());
%let time_elapsed = %sysfunc(intck(seconds,&hr_start,&hr_end));
%put TIME ELAPSED >>>>>>>>>>>>>>>>>>>  &time_elapsed SECONDS;

data _null_;
  file msg;
retain HS &hr_start HE &hr_end; put "BEGIN OF PROCESS: " HS datetime20.; put "END OF PROCESS: " HE datetime20.; put " "; put "database0_2 updated in &time_elapsed seconds."; run;

 

 

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
  • 1 reply
  • 1078 views
  • 0 likes
  • 2 in conversation