<?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: New to SAS: Code for Monthly Datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-Code-for-Monthly-Datasets/m-p/364136#M274998</link>
    <description>&lt;P&gt;Macros always run by calling them the same way so I suspect you're asking how to create a macro.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As to what you're trying to do I'm not sure, your explanation is unclear.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect you dont need macros at all. Append all datasets into one, using INDSNAME option to identify source data, and a PROC TRANSPOSE If you want it in a wide format.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 04 Jun 2017 16:28:16 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-06-04T16:28:16Z</dc:date>
    <item>
      <title>New to SAS: Code for Monthly Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-Code-for-Monthly-Datasets/m-p/364119#M274997</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an easy way to run a macro that allows you to quickly append the data you need from monthly files? eg. if you have spend data that is contained in monthly datasets (eg. Jan &amp;amp; Feb datasets spend_1701, spend_1702) and you wanted to trend spend over the last 12 months, instead of setting 12 datasets manually and keeping the spend value and renaming the spend variable whats the quickest way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jun 2017 14:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-Code-for-Monthly-Datasets/m-p/364119#M274997</guid>
      <dc:creator>aycee</dc:creator>
      <dc:date>2017-06-04T14:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS: Code for Monthly Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-Code-for-Monthly-Datasets/m-p/364136#M274998</link>
      <description>&lt;P&gt;Macros always run by calling them the same way so I suspect you're asking how to create a macro.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As to what you're trying to do I'm not sure, your explanation is unclear.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect you dont need macros at all. Append all datasets into one, using INDSNAME option to identify source data, and a PROC TRANSPOSE If you want it in a wide format.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jun 2017 16:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-Code-for-Monthly-Datasets/m-p/364136#M274998</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-04T16:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS: Code for Monthly Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-Code-for-Monthly-Datasets/m-p/364140#M274999</link>
      <description>&lt;P&gt;What code to generate I leave to you. &amp;nbsp;The "tricky" part is getting a value to increment over 12 strings that are in the format YYYYMM since it is not just a normal integer sequence. &amp;nbsp;That is 201612 is followed by 201701 instead of 201613.&lt;/P&gt;
&lt;P&gt;To generate 12 month strings you need to know a base date. &amp;nbsp;You can pick either the last or the first in the series. I suspect it is more likely that you know the last month rather than the first month.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let lastmonth="01MAY2017"d;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So to generate the previous twelve months in YYYYMM format you could use a loop like this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do offset=-11 %to 0;
   %let month=%sysfunc(intnx(month,&amp;amp;lastmonth,&amp;amp;offset),yymmn6);
    ....
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So if you just want to generate the string&lt;/P&gt;
&lt;PRE&gt;  spend_1603 spend_1604 .... spend_1702&lt;/PRE&gt;
&lt;P&gt;Then you might want a macro like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro dslist(prefix,lastmonth);
%local offset month ;
%do offset=-11 %to 0;
   %let month=%sysfunc(intnx(month,&amp;amp;lastmonth,&amp;amp;offset),yymmn6);
    &amp;amp;prefix.&amp;amp;month.
%end;
%mend dslist;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you could use it in a program like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set %dslist(spend_,"01FEB2017"D) ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Jun 2017 16:41:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-Code-for-Monthly-Datasets/m-p/364140#M274999</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-04T16:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: New to SAS: Code for Monthly Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-Code-for-Monthly-Datasets/m-p/364288#M275000</link>
      <description>&lt;P&gt;You may not need any macro or fancy code if you only need data within a given year and your data sets actually have the names you mention. There are list name shortcuts involving the colon character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set spend_17: ;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The colon says to include all of the data sets that start with spend_17 .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However your comment:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/147171"&gt;@aycee&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there an easy way to run a macro that allows you to quickly append the data you need from monthly files? eg. if you have spend data that is contained in monthly datasets (eg. Jan &amp;amp; Feb datasets spend_1701, spend_1702) and you wanted to trend spend over the last 12 months, instead of setting 12 datasets manually and keeping the spend value and&lt;FONT color="#008000"&gt; renaming the spend variable whats the quickest way to do this?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Abount renaming makes me think you want to do something that will add work. It is much better to have a variable with the date of the record and a single variable to hold the value than to create multiple variables with different names for each month. Let REPORT procedures do the human readable parts of column headings based on the date instead of forcing multiple variables into a difficult to manipulate process.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2017 14:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-to-SAS-Code-for-Monthly-Datasets/m-p/364288#M275000</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-05T14:58:14Z</dc:date>
    </item>
  </channel>
</rss>

