<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro variable in excel file name using ods in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669915#M201031</link>
    <description>&lt;P&gt;And for future convenience, replace the blank with an underline:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; PATH...\test_&amp;amp;run_date..xlsx&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;See Maxim 44.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jul 2020 15:55:25 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-07-16T15:55:25Z</dc:date>
    <item>
      <title>Macro variable in excel file name using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669898#M201019</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;I couldn't create an excel file that has macro value in the file name. I got error:&lt;/P&gt;&lt;P&gt;ERROR: Physical file does not exist, H:\&lt;SPAN style="font-family: inherit;"&gt;\test 16\07\2020.xlsx.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;I tested without using the &amp;amp;run_date macro variable, the code worked fine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Thanks for any help!&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data _null_;
	call symput("run_yyyy"  , put(year(date()),      Z4.));
	call symput("run_mon"   , put(month(date()),     Z2.));
	call symput("run_day"   , put(day(date()),       Z2.));
	call symput("run_hour"  , put(hour(datetime()),  Z2.));
	call symput("run_min"   , put(minute(datetime()),Z2.));
run;


%let run_date = &amp;amp;run_day./&amp;amp;run_mon./&amp;amp;run_yyyy.;
/* I also tried:
%let filepath = " PATH...\test &amp;amp;run_date..xlsx";
ods excel file=&amp;amp;filepath
*/
ods excel file=" PATH...\test &amp;amp;run_date..xlsx"
options(embedded_titles="yes" sheet_name="test" sheet_interval='none'); 
title "test";
proc print data=sashelp.cars;
run;
title;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:19:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669898#M201019</guid>
      <dc:creator>sasecn</dc:creator>
      <dc:date>2020-07-16T15:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable in excel file name using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669901#M201021</link>
      <description>&lt;PRE&gt;ERROR: Physical file does not exist, H:\\test 16\07\2020.xlsx.&lt;/PRE&gt;
&lt;P&gt;Typically on Windows computers, drive letters do not have double-slashes after the letter and colon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, if folder test 16 does not exist, or folder test 16\07 does not exist, then you get the error.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;So really, this is not a macro variable error at all. It is that you haven't constructed the path and file name to be in a folder that actually exists.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669901#M201021</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-16T15:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable in excel file name using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669905#M201023</link>
      <description>&lt;P&gt;You may also want to ensure you do not have any leading spaces inside the filename indicated by the quotes.&lt;/P&gt;
&lt;P&gt;This implies that you possibly have a space in your filename&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;ods excel file=" PATH...\test &amp;amp;run_date..xlsx"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;assuming the PATH is supposed to be a macro variable as well.&lt;/P&gt;
&lt;P&gt;I found out when we switched to OneDrive that file names became particular about a space. Where previously&lt;/P&gt;
&lt;P&gt;file = " d:\folder\file.xlxs" worked, note this is without any macro variable, I had similar errors. The correction was to use file= "d:\folder\file.xlsx" .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:34:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669905#M201023</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-16T15:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable in excel file name using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669906#M201024</link>
      <description>&lt;P&gt;Thanks for your reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am taking H:\\ as an example, my real path is a shared folder "\\PATH ...\test &amp;amp;run_date.xlsx". I am sure i have access to the folder. I tested that if i try "\\PATH ...\test.xlsx", the code worked. It created the excel file named "test.xlsx". I just wanted to created the excel file named by today's date, e.g "test 16\07\2020.xlsx"&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:34:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669906#M201024</guid>
      <dc:creator>sasecn</dc:creator>
      <dc:date>2020-07-16T15:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable in excel file name using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669909#M201026</link>
      <description>&lt;P&gt;Access to the folder is not the issue. You have named it wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Windows does not recognize H:\\ (with two slashes)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It does recognize \\path (with two slashes)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you have to get the folder name correct, and you have to use a folder that actually exists (if folder \\path\test 16\ doesn't exist, then you get the error)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly, a side issue ... Normally people create hierarchy that is Year\Month\Date, I really don't see a benefit of the way you are doing it which is Date/Month/Year, but I guess that's up to you.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:59:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669909#M201026</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-16T15:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable in excel file name using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669913#M201030</link>
      <description>&lt;P&gt;Simply do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let run_date = %sysfunc(putn(%sysfunc(date()),yymmddd10.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This replaces the (bad) slashes with (allowed) dashes, and also changes the date order to YMD, so the files sort automatically in chronological order.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:53:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669913#M201030</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-16T15:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable in excel file name using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669915#M201031</link>
      <description>&lt;P&gt;And for future convenience, replace the blank with an underline:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; PATH...\test_&amp;amp;run_date..xlsx&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;See Maxim 44.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 15:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669915#M201031</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-16T15:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable in excel file name using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669920#M201035</link>
      <description>&lt;P&gt;Do NOT try to make filenames that have / or \ as part of the name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let run_date = &amp;amp;run_yyyy._&amp;amp;run_mon._&amp;amp;run_day ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS When using dates as part of a filename always use YMD order instead of MDY or DMY. Then the names will sort lexicographically in chronological order and also avoid confusion&amp;nbsp; about which part is the month and which is the day.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 16:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669920#M201035</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-16T16:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable in excel file name using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669922#M201037</link>
      <description>&lt;P&gt;Thanks all for the reply!&lt;/P&gt;&lt;P&gt;Now, i understand that the slash in my original date caused the path reference problems.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 16:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-in-excel-file-name-using-ods/m-p/669922#M201037</guid>
      <dc:creator>sasecn</dc:creator>
      <dc:date>2020-07-16T16:10:27Z</dc:date>
    </item>
  </channel>
</rss>

