<?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: Grouping observations into new integer variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Grouping-observations-into-new-integer-variable/m-p/582181#M165540</link>
    <description>&lt;P&gt;One solution&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    if oldvar=1 then newvar=mod(_n_-1,3)+1;
    else if oldvar=2 then newvar=mod(_n_-1,3)+4;
    else if oldvar=3 then newvar=mod(_n_-1,3)+7;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which can be simplified to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    newvar=mod(_n_-1,3)+(oldvar-1)*3+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Aug 2019 17:23:30 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-08-19T17:23:30Z</dc:date>
    <item>
      <title>Grouping observations into new integer variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-observations-into-new-integer-variable/m-p/582175#M165535</link>
      <description>&lt;P&gt;I have a group variable that has 3 values. I want to convert it into a variable that has 9 values. I want to know that those in oldvar=1 became newvar=1,2,3, oldvar=2 became newvar=4-6, and oldvar=3 became newvar=7-9. However, within oldvar=1, the observations that take newvar=1, 2, or 3 can happen randomly or can happen where the first third become newvar= 1, the second third become newvar=2, and the last third become 3.&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 17:15:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-observations-into-new-integer-variable/m-p/582175#M165535</guid>
      <dc:creator>CatM</dc:creator>
      <dc:date>2019-08-19T17:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping observations into new integer variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-observations-into-new-integer-variable/m-p/582181#M165540</link>
      <description>&lt;P&gt;One solution&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    if oldvar=1 then newvar=mod(_n_-1,3)+1;
    else if oldvar=2 then newvar=mod(_n_-1,3)+4;
    else if oldvar=3 then newvar=mod(_n_-1,3)+7;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which can be simplified to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    newvar=mod(_n_-1,3)+(oldvar-1)*3+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 17:23:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-observations-into-new-integer-variable/m-p/582181#M165540</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-19T17:23:30Z</dc:date>
    </item>
  </channel>
</rss>

