<?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: Using mdy function to Extract the date and filter 12 months older data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606667#M176194</link>
    <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13573"&gt;@Paige&lt;/a&gt;. Would you please help on complete code please&lt;BR /&gt;</description>
    <pubDate>Sat, 23 Nov 2019 06:50:18 GMT</pubDate>
    <dc:creator>JJP1</dc:creator>
    <dc:date>2019-11-23T06:50:18Z</dc:date>
    <item>
      <title>Using mdy function to Extract the date and filter 12 months older data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606488#M176113</link>
      <description>Hi. I have a dataset contains year, month columns but I don't have day columns. So using this columns I need to write a condition to filter only 12months old records from today Please help. Year is holding as 2019 and month is 10</description>
      <pubDate>Fri, 22 Nov 2019 15:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606488#M176113</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-22T15:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using mdy function to Extract the date and filter 12 months older data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606492#M176117</link>
      <description>&lt;P&gt;Set the day to be 1 in the MDY function.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 15:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606492#M176117</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-22T15:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using mdy function to Extract the date and filter 12 months older data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606496#M176119</link>
      <description>&lt;P&gt;Here's an example. This dataset contains dates in the 1990's so I set today to 12/31/1994 but you can use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let tdy = %sysfunc(today(),date9.);
%put =&amp;amp;tdy;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let tdy = '31DEC1994'd;

data have;
set sashelp.prdsale;
format date date9.; 
month_num = month(month);
date = mdy(month_num,1,year);
run;

data want;
set have;
where date between intnx("month",&amp;amp;tdy.,-11,"b") and &amp;amp;tdy.;
run;

proc freq data=want; 
tables month*year /nocol nocum nopercent norow; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;-unison&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 15:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606496#M176119</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2019-11-22T15:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using mdy function to Extract the date and filter 12 months older data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606529#M176133</link>
      <description>&lt;P&gt;You have to do the hard part ... define the problem better.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Today is November 22, 2019.&amp;nbsp; Using only month and year, what month/year combinations would be included in your 12 month period?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once the rules are established, the programming would be relatively easy for many of the people who post here.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 18:07:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606529#M176133</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-11-22T18:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using mdy function to Extract the date and filter 12 months older data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606653#M176186</link>
      <description>Why at the end proc freq you are using please&lt;BR /&gt;</description>
      <pubDate>Sat, 23 Nov 2019 04:17:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606653#M176186</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-23T04:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using mdy function to Extract the date and filter 12 months older data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606661#M176190</link>
      <description>&lt;P&gt;Just as a check to make sure the correct observations are pulled.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-unison&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2019 04:58:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606661#M176190</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2019-11-23T04:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using mdy function to Extract the date and filter 12 months older data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606663#M176191</link>
      <description>Sorry for confusion.&lt;BR /&gt;I have below sample data&lt;BR /&gt;Number year month&lt;BR /&gt;19 2019 10&lt;BR /&gt;20 2019 10&lt;BR /&gt;30 2018. 5&lt;BR /&gt;&lt;BR /&gt;I want to keep the above data only for 12 months older .i can do this only&lt;BR /&gt;using year and month columns.&lt;BR /&gt;so sample output should exclude 2018 record as it is not 12 months older .&lt;BR /&gt;I know I can use mdy function.but Iam not sure how to apply the function.&lt;BR /&gt;Please help&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 23 Nov 2019 05:12:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606663#M176191</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-23T05:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using mdy function to Extract the date and filter 12 months older data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606667#M176194</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13573"&gt;@Paige&lt;/a&gt;. Would you please help on complete code please&lt;BR /&gt;</description>
      <pubDate>Sat, 23 Nov 2019 06:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606667#M176194</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-23T06:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using mdy function to Extract the date and filter 12 months older data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606673#M176198</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256123"&gt;@JJP1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13573"&gt;@Paige&lt;/a&gt;. Would you please help on complete code please&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What is wrong with the code from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/270457"&gt;@unison&lt;/a&gt; ?&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2019 11:36:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606673#M176198</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-23T11:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using mdy function to Extract the date and filter 12 months older data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606678#M176200</link>
      <description>&lt;P&gt;The key issue is still unaddressed.&amp;nbsp; Let me spell it out in a more specific way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following represent 3 dates on which the program might run:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;November 30, 2019&lt;/P&gt;
&lt;P&gt;December 1, 2019&lt;/P&gt;
&lt;P&gt;December 15, 2019&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each date, specify the first year/month and the last year/month you would like to include.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2019 14:44:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606678#M176200</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-11-23T14:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using mdy function to Extract the date and filter 12 months older data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606871#M176303</link>
      <description>&lt;P&gt;Hi JJP1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you mean all your data looks like this:&lt;/P&gt;&lt;P&gt;Year Month&lt;/P&gt;&lt;P&gt;2019 01&lt;/P&gt;&lt;P&gt;2018 02&lt;/P&gt;&lt;P&gt;2019 03&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But you dont have a day Variable? Is your intention to get the full 12 months regardless of the date?&lt;/P&gt;&lt;P&gt;E.g., today is Nov 25, 2019,&amp;nbsp; you want to include From Dec 01, 2018 to today?&lt;/P&gt;&lt;P&gt;Since you don't have day variable, you can default to 01 all the days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then read as yyyymmdd, then use intck to count 12 months from today&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ck ;
year=2019 ;
month=9 ;
new_month = COMPRESS(PUT(year,4.)||PUT(month,z2.)||"01") ;

FORMAT inputasdate date9. ;
inputasdate = INPUT(new_month,yymmdd8.) ;
_12months = intck("months",inputasdate, today()) ;

IF 0&amp;lt;= _12months &amp;lt;=12 ;
RUN ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please take note that the year and month, I suppose they are numbers&lt;/P&gt;&lt;P&gt;Please let us know if we get your issue correctly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 03:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-mdy-function-to-Extract-the-date-and-filter-12-months/m-p/606871#M176303</guid>
      <dc:creator>Pmyosh</dc:creator>
      <dc:date>2019-11-25T03:43:14Z</dc:date>
    </item>
  </channel>
</rss>

