DATA Step, Macro, Functions and more

Macro variable

Super Contributor
Posts: 426

Macro variable

See the log below. Can someone tell me how to call this macro variable in infile statement? Because I could not resolve the macro variable as per the log below.

1          %let filedate=%sysfunc(putn("&sysdate9"d-1,yymmdd10.));

2          %put &filedate;


ERROR: Physical file does not exist,


Note: I copy\paste only the required log and NOT everything.

Super User
Super User
Posts: 7,407

Re: Macro variable

I can't tell from the code you have given, how the infile statement looks.  It should look like:

infile "abc\def\&FILEDATE._tmp.csv";

However, why do you need the macro variable at all?

infile "abc\def\%sysfunc(putn("&sysdate9"d-1,yymmdd10.))_tmp.csv";

Trusted Advisor
Posts: 1,620

Re: Macro variable

Your error message could be interpreted as not a macro variable error, it could mean your macro variable has worked properly and your infile statement points to a file that doesn't exist.

It would help if you showed us the INFILE statement.

Super User
Super User
Posts: 6,502

Re: Macro variable

Looks like you used single quotes in the INFILE statement, so the macro variable was not expanded. Also I doubt the you want the double quote characters embedded into the filename.

infile "/usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/SASApp_STPServer_&filedate._tmptcmsaslva2_*.log" ...

Posts: 1,233

Re: Macro variable

Yes, please show your INFILE statement.

If that is really the error message you are getting, I would guess maybe your infile statement looks something like:

  infile '/usr/sas/.../SASApp_STPServer_"&filedate"_tmptcmsaslva1_*.log';

The single quotes would keep &filedate from resolving.   And you don't want double quotes in the middle of your file name.

Ask a Question
Discussion stats
  • 4 replies
  • 5 in conversation