08-30-2011 07:41 PM
I export a report to Excel daily, with the data in the filename changing each day as follows in an extract of the full code:
proc export data=summarylessgst1 outfile='H:\Output\Summary &endDate..xls'
I had no problem with this when using SAS 9.1, but now I have moved to SAS 9.2, the output does not recognise &endDate., and instead outputs a file named:
&endDate works fine in the rest of the code, i.e. when only selecting transactions with a date before &endDate. Can anyone help to provide an explanation and/or solution as to why the proc export outfile does not replace &endDate with the specified date?
08-30-2011 07:50 PM
I'm surprised that it worked correctly in 9.1. Enclose your filename in double quotes or else the macro variable won't resolve. I.e., use:
proc export data=summarylessgst1 outfile="H:\Output\Summary &endDate..xls"
08-30-2011 09:33 PM
Thanks art297, I changed to double quotations and it's now reading the macro variable properly. Yes I never thought that would be the issue since single quotations has always worked in SAS 9.1.
Glad it's resolved, thanks again for your help.
08-31-2011 04:51 PM
like with like it's hard to see how it works in 9.1
However, macro variable DATE referenced like '&date'd (holding a date like 31-Aug-2011) resolves OK for me, when it is within a longer double-quoted string
11-10-2011 06:43 AM
The outer most quotes are the ones that determine if macro references are resolved.
%let x1="The date value is '&date1' ";
%let x2='The date value is "&date1" ';
11-11-2011 05:53 AM
it's all about the outside quoting!
(are you adding something >>>>?
(why use superq?
(in what context does this need superq?
(%put x2=&x2 * demonstrate context 'where "&date1" does not resolve';
(%put x1=&x1 * demonstrate context "where '&date1' does resolve";
11-09-2011 07:19 PM
MikeSimmos & art297,
Thanks for posting this question and answer. I was attempting to do a similar operation and could not figure out how to get a macro variable to correctly work with in an ouput filename.