<?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: Reclassifying a decimal version of month in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reclassifying-a-decimal-version-of-month/m-p/767990#M243544</link>
    <description>&lt;P&gt;In general, fractional months don't make a lot of sense. The better solution, if possible, is to handle months as SAS date variables and then use actual SAS date functions such as INTCK to determine number of months since a given date. Then all of this repetitive coding goes away. SAS has done the hard work in computing months so you don't have to.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Sep 2021 19:48:53 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-09-15T19:48:53Z</dc:date>
    <item>
      <title>Reclassifying a decimal version of month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reclassifying-a-decimal-version-of-month/m-p/767987#M243541</link>
      <description>&lt;P&gt;I am trying to create a month variable from days; I divided my days variable by 30.5. My data looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Days Month 
1       0.0327
1       0.0327
1       0.0327
1       0.0327
1       0.0327
2       0.065  
2       0.065
2       0.065
2       0.065
2       0.065
2       0.065
3       0.098
3       0.098
3       0.098&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there an easier way to reclassify month other than 'if than else' statements? For example, I know I could do:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
set mydata;

if 0&amp;lt;=month&amp;lt;1 then month_new=1;
else if 1&amp;lt;=month&amp;lt;2 then month_new=2;
else if 2&amp;lt;=month&amp;lt;3 then month_new=3;
....
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But is there a more efficient way? For example, assuming there are thirteen months, I tried:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
retain month_new;
set mydata;

do i=1 to 13;
if i &amp;lt;= month &amp;lt; (i+1) then month_new=i;
end;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This applied the last number in the do loop, 13, to all data values.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 19:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reclassifying-a-decimal-version-of-month/m-p/767987#M243541</guid>
      <dc:creator>Caetreviop543</dc:creator>
      <dc:date>2021-09-15T19:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Reclassifying a decimal version of month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reclassifying-a-decimal-version-of-month/m-p/767990#M243544</link>
      <description>&lt;P&gt;In general, fractional months don't make a lot of sense. The better solution, if possible, is to handle months as SAS date variables and then use actual SAS date functions such as INTCK to determine number of months since a given date. Then all of this repetitive coding goes away. SAS has done the hard work in computing months so you don't have to.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 19:48:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reclassifying-a-decimal-version-of-month/m-p/767990#M243544</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-15T19:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Reclassifying a decimal version of month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reclassifying-a-decimal-version-of-month/m-p/767992#M243545</link>
      <description>&lt;P&gt;If you are trying to bin your days into 30 day intervals (not really months since months do not have a constant number of days during a year or in case of Feb even across different years) just use some arithmetic.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month=floor(days/30);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to count from 1 instead of 0 just add one.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 19:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reclassifying-a-decimal-version-of-month/m-p/767992#M243545</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-15T19:58:48Z</dc:date>
    </item>
  </channel>
</rss>

