<?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 Assigning ascending integers to an interval of dates in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Assigning-ascending-integers-to-an-interval-of-dates/m-p/900798#M40134</link>
    <description>&lt;P&gt;Hello, I have a dataset that lists dates, and the corresponding YYMMM (for example September 2021 is 21M09).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to take the interval of 21M02 to 23M09 and assign the values 1 through 32 to these in order.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using a macro is preferable in case I need to change this interval. Any suggestions? Thanks!!&lt;/P&gt;</description>
    <pubDate>Mon, 30 Oct 2023 20:00:02 GMT</pubDate>
    <dc:creator>l3xrink</dc:creator>
    <dc:date>2023-10-30T20:00:02Z</dc:date>
    <item>
      <title>Assigning ascending integers to an interval of dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-ascending-integers-to-an-interval-of-dates/m-p/900798#M40134</link>
      <description>&lt;P&gt;Hello, I have a dataset that lists dates, and the corresponding YYMMM (for example September 2021 is 21M09).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to take the interval of 21M02 to 23M09 and assign the values 1 through 32 to these in order.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using a macro is preferable in case I need to change this interval. Any suggestions? Thanks!!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2023 20:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-ascending-integers-to-an-interval-of-dates/m-p/900798#M40134</guid>
      <dc:creator>l3xrink</dc:creator>
      <dc:date>2023-10-30T20:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning ascending integers to an interval of dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-ascending-integers-to-an-interval-of-dates/m-p/900804#M40135</link>
      <description>Why? How are you storing these dates?&lt;BR /&gt;If you have them as SAS dates with a format, they'll sort correctly.</description>
      <pubDate>Mon, 30 Oct 2023 20:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-ascending-integers-to-an-interval-of-dates/m-p/900804#M40135</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-10-30T20:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning ascending integers to an interval of dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-ascending-integers-to-an-interval-of-dates/m-p/900805#M40136</link>
      <description>Hi there are multiple rows that i would like to assign the value of 1,2, etc. depending on the value of YYMMM.</description>
      <pubDate>Mon, 30 Oct 2023 20:54:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-ascending-integers-to-an-interval-of-dates/m-p/900805#M40136</guid>
      <dc:creator>l3xrink</dc:creator>
      <dc:date>2023-10-30T20:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning ascending integers to an interval of dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-ascending-integers-to-an-interval-of-dates/m-p/900806#M40137</link>
      <description>That doesn't actually answer the question. Why the 1/2, etc? I would assume the dates would be more relevant. &lt;BR /&gt;&lt;BR /&gt;Either way, the type of the variable, numeric with date format or character does matter to how a solution is developed. In this situation, a format is recommended, where you create the format via  macro with the start date and number of intervals or end date.  The format applied will always have the same name saving one step at least.</description>
      <pubDate>Mon, 30 Oct 2023 21:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-ascending-integers-to-an-interval-of-dates/m-p/900806#M40137</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-10-30T21:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning ascending integers to an interval of dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-ascending-integers-to-an-interval-of-dates/m-p/900810#M40138</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/459713"&gt;@l3xrink&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi there are multiple rows that i would like to assign the value of 1,2, etc. depending on the value of YYMMM.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you want to assign 1,2,3 just use a retained variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by id;
  seq+1;
  if first.id then seq=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to convert MONTH into relative month number then use INTCK() function.&amp;nbsp; Add one if you want to number from 1 instead of from 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;If they are not already dates that just have the YYMM5. format attached (who displays dates without the century number?).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let basedate = '01jan2011'd;
data want;
  set have;
  month_number = 1 + intck('month',&amp;amp;basedate,yymmm);
run;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If they are strings then first convert them into a date value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let basedate = '01jan2011'd;
data want;
  set have;
  month_number = 1 + intck('month',&amp;amp;basedate,input(cats(compress(yymmm,'Mm'),'01'),yymmdd.));
run;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2023 21:13:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-ascending-integers-to-an-interval-of-dates/m-p/900810#M40138</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-10-30T21:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning ascending integers to an interval of dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-ascending-integers-to-an-interval-of-dates/m-p/900831#M40139</link>
      <description>We don't really know whether your variable is character or numeric.  If it is character, consider the possibility of doing nothing.  The values are already in sorted order.  And they would be easy to subset:&lt;BR /&gt;&lt;BR /&gt;if "22M07" &amp;lt;= date &amp;lt;= "23M02";&lt;BR /&gt;&lt;BR /&gt;Do you really want to create the situation where the value "32" changes its meaning  depending on the data set that was used?</description>
      <pubDate>Mon, 30 Oct 2023 22:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-ascending-integers-to-an-interval-of-dates/m-p/900831#M40139</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-10-30T22:43:26Z</dc:date>
    </item>
  </channel>
</rss>

