Hi all,
I try to do something easy, it's not working.
So frustrating!
data _null_; call symput('EXECTIME', time()); put &EXECTIME.; run;
The mistake is:
WARNING: Apparent symbolic reference EXECTIME not resolved.
And for the put line:
ERROR 22-322: Expecting a name.
What is wrong with this??
Thank you for your help 😉
In SAS, as in life, timing is everything.
The software examines the statements within the DATA step, performing any set-up work and checking for syntax errors. It does this before actually executing the DATA step, and before executing CALL SYMPUT. Therefore, the software comes up with a syntax error in the PUT statement, since the macro variable has not yet been created. An alternative version:
data _null_;
call symputx('EXECTIME', time());
run;
%put &EXECTIME.;
Also note how switching to CALL SYMPUTX gets rid of any messages about numeric to character conversion.
In SAS, as in life, timing is everything.
The software examines the statements within the DATA step, performing any set-up work and checking for syntax errors. It does this before actually executing the DATA step, and before executing CALL SYMPUT. Therefore, the software comes up with a syntax error in the PUT statement, since the macro variable has not yet been created. An alternative version:
data _null_;
call symputx('EXECTIME', time());
run;
%put &EXECTIME.;
Also note how switching to CALL SYMPUTX gets rid of any messages about numeric to character conversion.
So stupid! ^^
Thanks Astounding!
You ar enot stupid
Here are a few solutions
data _null_;
call symput('EXECTIME', put(time(),hhmm5.));
time=symget('exectime');
put time=;
run;quit;
%symdel exectime;
data _null_;
if _n_=0 then do;
%let rc=%sysfunc(dosubl('
%let exectime=%sysfunc(putn(%sysfunc(time()),HHMM5.));
'));
end;
put "&EXECTIME.";
run;
11:43
%symdel exectime;
data _null_;
if _n_=0 then do;
%let rc=%sysfunc(dosubl('
proc sql;
select put(time(),hhmm.) into :exectime from sashelp.class(obs=1)
;quit;
'));
end;
put "&exectime";
run;quit;
%symdel exectime;
data _null_;
if _n_=0 then do;
%let rc=%sysfunc(dosubl('
data _null_;
call symputx("EXECTIME", put(time(),hhmm5.),'G');
;run;
'));
end;
put "&exectime";
run;quit;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.