Reputation: 726
I'm trying to write tiny programm with parameters to backup datasets (name+date+time) in Enterprise Guide. Here's code:
data &WhatLib..&WhatTable%str(_)&SYSDATE.%sysfunc(tranwrd(%str(&SYSTIME.),:,_)) ;
set &WhatLib..&WhatTable ;
run;
WhatLib
(default value work) and WhatTable
(default value _PRODSAVAIL) - parameters. Well, I get result, that in the screenshot:
I added a few more strings to check macro variables values:
%put &WhatLib..&WhatTable%str(_)&SYSDATE.%sysfunc(tranwrd(%str(&SYSTIME.),:,_));
%put &WhatLib..&WhatTable;
And result is in log was:
work._PRODSAVAIL_22AUG1613_28
work._PRODSAVAIL
Then, I wrapped this code into macro defenition:
%macro TEST();
...
<--same code-->
...
%mend TEST;
%TEST();
But result were the same. I will be grateful if you specify an error or feature that I did not realize.
Upvotes: 1
Views: 116
Reputation: 629
The %STR(_)
is causing problem here. You don't need to put _
in the %STR()
macro function. Underscore is proper part of name in data sets.
Also it is better to use %SYSFUNC()
with TIME()
and DATE()
functions to have actual time and date. Not the SAS starting time and date:
data &WhatLib..&WhatTable._%sysfunc(date(),date9.)_%sysfunc(tranwrd(%sysfunc(time(),hhmm5.),:,_));
set &WhatLib..&WhatTable;
run;
Upvotes: 3