<?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: Creating and referencing dynamically named datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-and-referencing-dynamically-named-datasets/m-p/409563#M100057</link>
    <description>&lt;P&gt;Look at INTNX to increment yoru dates automatically.&amp;nbsp;&lt;BR /&gt;Remember that you can use CALL SYMPUTX within a DATA _NULL_ step to create your macro variables, if that's easier.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think this has relevant examples for you - including how to loop through dates if desired.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may need to tweak your code a bit to handle the unquoted/d on the date variable. YOu can either leave them as numbers and trust SAS is doing it correctly, or you can use DATE9 Format to create them as DATE9 date values and quote/add D in the report code instead. The second approach is a bit more user friendly;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;

report_date = '31Dec2017'd;
yesterday = report_Date - 1;
last_week = report_date - 7;

call symputx('Report_Date', report_date);&lt;BR /&gt;call symputx('myDate', put(Report_date, date9.));
.....
....

run;

%put &amp;amp;report_date;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Nov 2017 17:43:39 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-11-01T17:43:39Z</dc:date>
    <item>
      <title>Creating and referencing dynamically named datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-and-referencing-dynamically-named-datasets/m-p/409555#M100054</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let Report_Date = '31Dec2017'd;&lt;BR /&gt;%let yesterday= '30Dec2017'd;&lt;BR /&gt;%let last_week = '24Dec2017'd;&lt;BR /&gt;DATA example&amp;amp;Report_Date.;&lt;BR /&gt;    set example;&lt;BR /&gt;    /* do stuff */&lt;BR /&gt;RUN;&lt;BR /&gt;DATA example_compare_yesterday;&lt;BR /&gt;   set example&amp;amp;Report_Date. example&amp;amp;yesterday.;&lt;BR /&gt;RUN;&lt;BR /&gt;DATA example_compare_last_week;&lt;BR /&gt;   set example&amp;amp;report_Date. example&amp;amp;last_week.;&lt;BR /&gt;RUN;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to make this code iterative, but don't have much of a grounding in macros (which I assume would be appropriate).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to do the following:&lt;/P&gt;&lt;P&gt;On any given date, "Report_Date" will have the current date&lt;/P&gt;&lt;P&gt;I would like to automatically populate "yesterday"&amp;nbsp;and "last week" with the relevant date such that I can generate the comparative datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I have to populate all three dates to make this work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 17:31:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-and-referencing-dynamically-named-datasets/m-p/409555#M100054</guid>
      <dc:creator>MikeFranz</dc:creator>
      <dc:date>2017-11-01T17:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and referencing dynamically named datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-and-referencing-dynamically-named-datasets/m-p/409563#M100057</link>
      <description>&lt;P&gt;Look at INTNX to increment yoru dates automatically.&amp;nbsp;&lt;BR /&gt;Remember that you can use CALL SYMPUTX within a DATA _NULL_ step to create your macro variables, if that's easier.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think this has relevant examples for you - including how to loop through dates if desired.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may need to tweak your code a bit to handle the unquoted/d on the date variable. YOu can either leave them as numbers and trust SAS is doing it correctly, or you can use DATE9 Format to create them as DATE9 date values and quote/add D in the report code instead. The second approach is a bit more user friendly;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;

report_date = '31Dec2017'd;
yesterday = report_Date - 1;
last_week = report_date - 7;

call symputx('Report_Date', report_date);&lt;BR /&gt;call symputx('myDate', put(Report_date, date9.));
.....
....

run;

%put &amp;amp;report_date;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 17:43:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-and-referencing-dynamically-named-datasets/m-p/409563#M100057</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-01T17:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and referencing dynamically named datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-and-referencing-dynamically-named-datasets/m-p/409735#M100126</link>
      <description>This is great, thank you! I didn't know about this data _null_ option, very useful!</description>
      <pubDate>Thu, 02 Nov 2017 08:57:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-and-referencing-dynamically-named-datasets/m-p/409735#M100126</guid>
      <dc:creator>MikeFranz</dc:creator>
      <dc:date>2017-11-02T08:57:08Z</dc:date>
    </item>
  </channel>
</rss>

