<?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 Assign number to group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assign-number-to-group/m-p/609265#M177379</link>
    <description>&lt;P&gt;I have to assign numbers to groups in two ways. First I was able to achieve(pt_id). The other one, I want to assign the same number to each soc, so in this case, soc1 will have value 1 for all first 3 rows. And soc 2 will have value of 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data in;&lt;BR /&gt;input soc $ pt $;&lt;BR /&gt;datalines ;&lt;BR /&gt;soc1 pt1&lt;BR /&gt;soc1 pt2&lt;BR /&gt;soc1 pt8&lt;BR /&gt;soc2 pt1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data out;&lt;BR /&gt;set in;&lt;BR /&gt;by soc pt;&lt;BR /&gt;if first.soc then pt_id=0;&lt;BR /&gt;pt_id+1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output, should look like this...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;soc&amp;nbsp; &amp;nbsp;pt&amp;nbsp; &amp;nbsp; &amp;nbsp; pt_id soc_id&lt;/P&gt;&lt;P&gt;____________________&lt;/P&gt;&lt;P&gt;soc1 pt1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;soc1 pt2&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;soc1 pt8&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;soc2 pt1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I should add in the datastep to get he soc_id.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Wed, 04 Dec 2019 05:34:43 GMT</pubDate>
    <dc:creator>sonicview</dc:creator>
    <dc:date>2019-12-04T05:34:43Z</dc:date>
    <item>
      <title>Assign number to group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-number-to-group/m-p/609265#M177379</link>
      <description>&lt;P&gt;I have to assign numbers to groups in two ways. First I was able to achieve(pt_id). The other one, I want to assign the same number to each soc, so in this case, soc1 will have value 1 for all first 3 rows. And soc 2 will have value of 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data in;&lt;BR /&gt;input soc $ pt $;&lt;BR /&gt;datalines ;&lt;BR /&gt;soc1 pt1&lt;BR /&gt;soc1 pt2&lt;BR /&gt;soc1 pt8&lt;BR /&gt;soc2 pt1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data out;&lt;BR /&gt;set in;&lt;BR /&gt;by soc pt;&lt;BR /&gt;if first.soc then pt_id=0;&lt;BR /&gt;pt_id+1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output, should look like this...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;soc&amp;nbsp; &amp;nbsp;pt&amp;nbsp; &amp;nbsp; &amp;nbsp; pt_id soc_id&lt;/P&gt;&lt;P&gt;____________________&lt;/P&gt;&lt;P&gt;soc1 pt1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;soc1 pt2&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;soc1 pt8&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;soc2 pt1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I should add in the datastep to get he soc_id.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 05:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-number-to-group/m-p/609265#M177379</guid>
      <dc:creator>sonicview</dc:creator>
      <dc:date>2019-12-04T05:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Assign number to group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-number-to-group/m-p/609267#M177381</link>
      <description>&lt;P&gt;please try the below code , only update is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if first.soc then soc_id+1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data out;
set in;
by soc pt;
if first.soc then pt_id=0;
pt_id+1;
if first.soc then soc_id+1;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Dec 2019 05:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-number-to-group/m-p/609267#M177381</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-12-04T05:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: Assign number to group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-number-to-group/m-p/609293#M177392</link>
      <description>&lt;P&gt;See this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data out;
set in;
by soc pt;
if first.soc
then do;
  soc_id + 1;
  pt_id = 1;
end;
else if first.pt then pt_id + 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Dec 2019 08:13:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-number-to-group/m-p/609293#M177392</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-04T08:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: Assign number to group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-number-to-group/m-p/609329#M177401</link>
      <description>&lt;P&gt;This should do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set in;
  by soc pt;
  if first.soc then do;
    pt_id=1;
    soc_id+1;
    end;
  else
    pt_id+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Dec 2019 10:39:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-number-to-group/m-p/609329#M177401</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-12-04T10:39:28Z</dc:date>
    </item>
  </channel>
</rss>

