<?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 Month flag variable using a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Month-flag-variable-using-a-macro/m-p/22881#M3736</link>
    <description>I'm new to this forum.  Can you advise how to create a month/year variable using a macro?  I have individual monthly files that I will merge together to look at trends.  However when I try the code below, I either get missing data or if I turn it into a character variable, the "&amp;amp;i." becomes the variable.  I'd appreciate any guidance you can send my way.  Thanks!&lt;BR /&gt;
&lt;BR /&gt;
%macro date;&lt;BR /&gt;
%do i = 4 %to 12;&lt;BR /&gt;
data total_&amp;amp;i._2009;&lt;BR /&gt;
	set tier.total_&amp;amp;i._2009;&lt;BR /&gt;
date = &amp;amp;i._2009;&lt;BR /&gt;
%end;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend date;&lt;BR /&gt;
%date</description>
    <pubDate>Tue, 26 Oct 2010 16:42:30 GMT</pubDate>
    <dc:creator>ALF</dc:creator>
    <dc:date>2010-10-26T16:42:30Z</dc:date>
    <item>
      <title>Month flag variable using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-flag-variable-using-a-macro/m-p/22881#M3736</link>
      <description>I'm new to this forum.  Can you advise how to create a month/year variable using a macro?  I have individual monthly files that I will merge together to look at trends.  However when I try the code below, I either get missing data or if I turn it into a character variable, the "&amp;amp;i." becomes the variable.  I'd appreciate any guidance you can send my way.  Thanks!&lt;BR /&gt;
&lt;BR /&gt;
%macro date;&lt;BR /&gt;
%do i = 4 %to 12;&lt;BR /&gt;
data total_&amp;amp;i._2009;&lt;BR /&gt;
	set tier.total_&amp;amp;i._2009;&lt;BR /&gt;
date = &amp;amp;i._2009;&lt;BR /&gt;
%end;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend date;&lt;BR /&gt;
%date</description>
      <pubDate>Tue, 26 Oct 2010 16:42:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-flag-variable-using-a-macro/m-p/22881#M3736</guid>
      <dc:creator>ALF</dc:creator>
      <dc:date>2010-10-26T16:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: Month flag variable using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-flag-variable-using-a-macro/m-p/22882#M3737</link>
      <description>Reviewing your code, I believe that you are attempting to assign "date" as a SAS DATE (numeric type) variable, possibly?  Although you have no FORMAT statement defined.&lt;BR /&gt;
&lt;BR /&gt;
You may need to look at using the MDY function to assign your SAS DATE variable and also use a FORMAT statement to assign "date" to the desired output format display.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.

Message was edited by: sbb</description>
      <pubDate>Tue, 26 Oct 2010 16:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-flag-variable-using-a-macro/m-p/22882#M3737</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-10-26T16:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Month flag variable using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-flag-variable-using-a-macro/m-p/22883#M3738</link>
      <description>Perhaps you can read all the monthly files into one data set and create a month flag in one step.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
libname tier '.';&lt;BR /&gt;
data tier.total_4_2009 tier.total_5_2009 tier.total_6_2009 tier.total_7_2009 tier.total_8_2009;&lt;BR /&gt;
   do j = 1 to 4;&lt;BR /&gt;
      output;&lt;BR /&gt;
      end;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data total;&lt;BR /&gt;
   set tier.total_: indsname=indsname;&lt;BR /&gt;
   date = input(cats('01',substr(indsname,index(indsname,'_'))),mmddyy12.);&lt;BR /&gt;
   format date yymm.;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 26 Oct 2010 17:28:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-flag-variable-using-a-macro/m-p/22883#M3738</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-10-26T17:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Month flag variable using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-flag-variable-using-a-macro/m-p/22884#M3739</link>
      <description>Hello ALF,&lt;BR /&gt;
&lt;BR /&gt;
This is a possible solution:&lt;BR /&gt;
&lt;BR /&gt;
%macro date;&lt;BR /&gt;
%do i = 4 %to 12;&lt;BR /&gt;
data total_&amp;amp;i._2009;&lt;BR /&gt;
set tier.total_&amp;amp;i._2009;&lt;BR /&gt;
date = MDY(&amp;amp;i.,01,2009);&lt;BR /&gt;
format date date7.;&lt;BR /&gt;
run;&lt;BR /&gt;
%end;&lt;BR /&gt;
%mend date;&lt;BR /&gt;
%date &lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 26 Oct 2010 17:33:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-flag-variable-using-a-macro/m-p/22884#M3739</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-10-26T17:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: Month flag variable using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-flag-variable-using-a-macro/m-p/22885#M3740</link>
      <description>Thanks SPR, this code does just what I need!  ALF</description>
      <pubDate>Tue, 26 Oct 2010 17:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-flag-variable-using-a-macro/m-p/22885#M3740</guid>
      <dc:creator>ALF</dc:creator>
      <dc:date>2010-10-26T17:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: Month flag variable using a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-flag-variable-using-a-macro/m-p/22886#M3741</link>
      <description>For future reference, there's a lot of good info on using SAS dates here:&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a002200738.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a002200738.htm&lt;/A&gt;</description>
      <pubDate>Mon, 13 Dec 2010 15:20:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-flag-variable-using-a-macro/m-p/22886#M3741</guid>
      <dc:creator>PatrickG</dc:creator>
      <dc:date>2010-12-13T15:20:49Z</dc:date>
    </item>
  </channel>
</rss>

