<?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: Automate file naming with date value that is 7 day from today in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Automate-file-naming-with-date-value-that-is-7-day-from-today/m-p/256664#M309933</link>
    <description>&lt;P&gt;Welcome to the world of macro variables.&lt;/P&gt;
&lt;P&gt;Create a macro variable that is 7 days from today. Replace the portion of your code that is the date with the macro variable reference, in this case: &amp;amp;cdate_7.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like to use a data _null_ step to create my macro variables as it's more intuitive. You could do it with just a single %let statement. There's a lot of code an examples online, once you know what to search for.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
cdate=today();
cdate_7 = today()-7;

call symputx('cdate_7', put(cdate_7, yymmddn8.));
run;

%put &amp;amp;cdate_7.;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then modify your code accordingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets lib = xls nolist ;
delete Q&amp;amp;cdate_7. ;
quit ;
 
data xls.Q&amp;amp;cdate_7.;
set THISMONTH ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Good Luck!&lt;/P&gt;</description>
    <pubDate>Tue, 15 Mar 2016 01:00:33 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-03-15T01:00:33Z</dc:date>
    <item>
      <title>Automate file naming with date value that is 7 day from today</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-file-naming-with-date-value-that-is-7-day-from-today/m-p/256663#M309932</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;Hey guys.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;I have a created a program that is going to grab data from one excel spreadsheet and chuck it into another one&amp;nbsp;weekly. It is going to import the data into a specific named range for that week.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;My question - Is there any code&lt;FONT face="arial,helvetica,sans-serif"&gt; that I can use that&lt;/FONT&gt; changings the name in my code to the date 7 days ago?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;For example, this is part of my current code - &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;libname&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; xls &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;excel&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;'H:\TEST.xlsm'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;datasets&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;lib&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; = xls &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;nolist&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;delete&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;Q20160210 ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; xls.Q20160210 ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; THISMONTH ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;libname&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; xls &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;clear&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Is there any way to get the progame to automatically change Q(Date) to Q(Todays Date - 7)?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Hopefully this makes sense and thanks in advance.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Josh&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 01:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-file-naming-with-date-value-that-is-7-day-from-today/m-p/256663#M309932</guid>
      <dc:creator>joshua_james</dc:creator>
      <dc:date>2016-03-15T01:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Automate file naming with date value that is 7 day from today</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-file-naming-with-date-value-that-is-7-day-from-today/m-p/256664#M309933</link>
      <description>&lt;P&gt;Welcome to the world of macro variables.&lt;/P&gt;
&lt;P&gt;Create a macro variable that is 7 days from today. Replace the portion of your code that is the date with the macro variable reference, in this case: &amp;amp;cdate_7.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like to use a data _null_ step to create my macro variables as it's more intuitive. You could do it with just a single %let statement. There's a lot of code an examples online, once you know what to search for.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
cdate=today();
cdate_7 = today()-7;

call symputx('cdate_7', put(cdate_7, yymmddn8.));
run;

%put &amp;amp;cdate_7.;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then modify your code accordingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets lib = xls nolist ;
delete Q&amp;amp;cdate_7. ;
quit ;
 
data xls.Q&amp;amp;cdate_7.;
set THISMONTH ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Good Luck!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 01:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-file-naming-with-date-value-that-is-7-day-from-today/m-p/256664#M309933</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-15T01:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Automate file naming with date value that is 7 day from today</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-file-naming-with-date-value-that-is-7-day-from-today/m-p/256670#M309934</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let q=%sysfunc(intnx(day,%sysfunc(today()),-7),yymmddn8.);

%put &amp;amp;q ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Mar 2016 01:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-file-naming-with-date-value-that-is-7-day-from-today/m-p/256670#M309934</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-15T01:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Automate file naming with date value that is 7 day from today</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-file-naming-with-date-value-that-is-7-day-from-today/m-p/256676#M309935</link>
      <description>&lt;P&gt;&amp;nbsp;Worked perfectly! Thanks heaps! You have freed up my Monday's haha!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 02:11:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-file-naming-with-date-value-that-is-7-day-from-today/m-p/256676#M309935</guid>
      <dc:creator>joshua_james</dc:creator>
      <dc:date>2016-03-15T02:11:30Z</dc:date>
    </item>
  </channel>
</rss>

