<?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: Subtract one month from a numeric YYYYMM in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Subtract-one-month-from-a-numeric-YYYYMM/m-p/378082#M24593</link>
    <description>&lt;P&gt;Thank you, this seems to work just fine. Only I need to have the date stored as a numeric since the datawarehouse stores dates as integers. So I've gotten the YYYYMM I needed in date format. How do I get it back to an integer with the same numbers (YYYYMM)?&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jul 2017 11:52:52 GMT</pubDate>
    <dc:creator>Caribu</dc:creator>
    <dc:date>2017-07-21T11:52:52Z</dc:date>
    <item>
      <title>Subtract one month from a numeric YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Subtract-one-month-from-a-numeric-YYYYMM/m-p/378071#M24589</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a numeric format column with YYYYMM from which I would like to subtract one month which is fine unless the month is january. How can I make the code for when YYYYMM = XXXX01 then it should subtract 89 instead of 1 inorder to get the right year and month? In other words, how can I tell SAS to only look at the last to digits (ie MM)&amp;nbsp;to decide if it should subtract by 89 or 1?&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Your help is much appreciated!&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 11:10:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Subtract-one-month-from-a-numeric-YYYYMM/m-p/378071#M24589</guid>
      <dc:creator>Caribu</dc:creator>
      <dc:date>2017-07-21T11:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract one month from a numeric YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Subtract-one-month-from-a-numeric-YYYYMM/m-p/378074#M24590</link>
      <description>&lt;P&gt;Use the SAS function intnx, this takes into account years:&lt;/P&gt;
&lt;PRE&gt;want=intnx('month',your_date,-1);&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jul 2017 11:14:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Subtract-one-month-from-a-numeric-YYYYMM/m-p/378074#M24590</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-21T11:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract one month from a numeric YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Subtract-one-month-from-a-numeric-YYYYMM/m-p/378078#M24592</link>
      <description>&lt;P&gt;First of all, dates and date-related values should always be kept as SAS date values, and formatted as needed.&lt;/P&gt;
&lt;P&gt;For months, you store the first of the month and use a format that displays only year and month.&lt;/P&gt;
&lt;P&gt;So you first convert your value, and then use the proper function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
datevar = input(put(datevar,6.)!!'01',yymmdd8.);
format datevar yymmn6.;
datevar = intnx('month',datevar,-1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 11:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Subtract-one-month-from-a-numeric-YYYYMM/m-p/378078#M24592</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-21T11:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract one month from a numeric YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Subtract-one-month-from-a-numeric-YYYYMM/m-p/378082#M24593</link>
      <description>&lt;P&gt;Thank you, this seems to work just fine. Only I need to have the date stored as a numeric since the datawarehouse stores dates as integers. So I've gotten the YYYYMM I needed in date format. How do I get it back to an integer with the same numbers (YYYYMM)?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 11:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Subtract-one-month-from-a-numeric-YYYYMM/m-p/378082#M24593</guid>
      <dc:creator>Caribu</dc:creator>
      <dc:date>2017-07-21T11:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract one month from a numeric YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Subtract-one-month-from-a-numeric-YYYYMM/m-p/378102#M24597</link>
      <description>&lt;P&gt;Just do the conversion to a new variable, so you keep the original one. Although there is absolutely no reason for it. Dates are dates, storing them any other way just causes unnecessary work (you experienced that right here!) and is therefore stupid. I don't advise SAS newbies to do stupid things.&lt;/P&gt;
&lt;P&gt;And keep in mind that SAS also stores dates as integers, counting the days from 01-01-1960 in both directions. That's why i could convert in place.&lt;/P&gt;
&lt;P&gt;This is also the method used by all database systems and spreadsheet calculators I know of. They just use different basedates (31-12-1899 with most spreadsheet sw).&lt;/P&gt;
&lt;P&gt;The yymmn6. format already displays the data the way you want it, so you just need to input that into a number:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;silly_date = input(put(real_date,yymmn6.),6.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 12:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Subtract-one-month-from-a-numeric-YYYYMM/m-p/378102#M24597</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-21T12:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract one month from a numeric YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Subtract-one-month-from-a-numeric-YYYYMM/m-p/378108#M24598</link>
      <description>Thank you very much!</description>
      <pubDate>Fri, 21 Jul 2017 12:38:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Subtract-one-month-from-a-numeric-YYYYMM/m-p/378108#M24598</guid>
      <dc:creator>Caribu</dc:creator>
      <dc:date>2017-07-21T12:38:19Z</dc:date>
    </item>
  </channel>
</rss>

