1

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:

first version of code result

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.

1 Answer 1

3

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.