Question

I'm trying to generate a variable file name.

ods pdf file = "D:\FileDirectory\&&mFileNameVariable&I .pdf" notoc;

This generates a variable file name but adds a space before the extension (eg. FileName .pdf; I need FileName.pdf).

I read that you could do something like this:

ods pdf file = "D:\FileDirectory\&&mFileNameVariable&I..pdf" notoc;

To add the dot for the extension; however, when I try that macro doesn't work, I get a WYSIWYG value (eg. &&mFileNameVariable&I.pdf).

I'm assuming its because my string ends with a "&I".

Another solution I thought of, but it seams unnecessary / workaround is to trim(FilePathAndName) and, or concatinate cats(of FilePathAndName FileExtension) the values seperately.

Any insight or feedback is much appreciated, thank you in advance for your time and help.

Cheers!

Was it helpful?

Solution

Since you are doing two passes through the macro resolution process, you need an extra period between the filename and the extension (three total, 2 get munched during macro resolution, one to represent the separator).

e.g.

%let mFileNameVariable1=myfile;
%let l=1;
ods pdf file="C:\Temp\&&mFileNameVariable&l...pdf" notoc;  /*note 3 periods!!*/

On Log

NOTE: Writing ODS PDF output to DISK destination "C:\Temp\myfile.pdf", printer "PDF".
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top