<?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: Count combination of value instances across multiple by groups in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-combination-of-value-instances-across-multiple-by-groups/m-p/610586#M177821</link>
    <description>&lt;P&gt;First.id is not true (=1) when this is not a new id. You only need first.group :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set test;
by id group;
if first.group 
	then enroll_ord = 1; 
 	else enroll_ord + 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 09 Dec 2019 23:20:44 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2019-12-09T23:20:44Z</dc:date>
    <item>
      <title>Count combination of value instances across multiple by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-combination-of-value-instances-across-multiple-by-groups/m-p/610558#M177811</link>
      <description>&lt;P&gt;&lt;FONT color="#000000" face="helvetica"&gt;&lt;FONT size="2"&gt;SAS &lt;/FONT&gt;&lt;FONT size="2"&gt;9.4&lt;/FONT&gt;&lt;FONT size="2"&gt;:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="helvetica"&gt;&lt;FONT size="2"&gt;I am trying to count enrollment orders where an individual can enroll multiple times in multiple &lt;/FONT&gt;&lt;FONT size="2"&gt;groups.&lt;/FONT&gt;&lt;FONT size="2"&gt; In this case, I&lt;/FONT&gt;&lt;FONT size="2"&gt;'d like to count the enrollment order for each group separately. Using the by statement with first.id, I can count the OVERALL enrollment order. But I'd&lt;/FONT&gt;&lt;FONT size="2"&gt; like to count an enrollment in a different group as a completely new enrollment, even if this individual had already enrolled in a different &lt;/FONT&gt;&lt;FONT size="2"&gt;group.&lt;/FONT&gt;&lt;FONT size="2"&gt; So, in the example below, dataline &lt;/FONT&gt;&lt;FONT size="2"&gt;2&lt;/FONT&gt;&lt;FONT size="2"&gt; where id &lt;/FONT&gt;&lt;FONT size="2"&gt;1001&lt;/FONT&gt;&lt;FONT size="2"&gt; enrolled in group &lt;/FONT&gt;&lt;FONT size="2"&gt;2&lt;/FONT&gt;&lt;FONT size="2"&gt; should be given an enrollment order of &lt;/FONT&gt;&lt;FONT size="2"&gt;1.&lt;/FONT&gt;&lt;FONT size="2"&gt; (If you run the example below, it&lt;/FONT&gt;&lt;FONT size="2"&gt;'s not working that way)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="helvetica"&gt;...and without using a concatenation of id and group.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input id group date;
datalines;
1001 1 22100
1001 2 22200
1001 1 22300
1001 1 22400
1002 2 22500
1002 2 22600
1002 2 22700
;
run;

proc sort data = test;  
  by id group date;
run;

data test;
	set test;
	by id group;
	 	if (first.id) and (first.group) then enroll_ord = 1; 
	 		else enroll_ord + 1;
proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 21:21:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-combination-of-value-instances-across-multiple-by-groups/m-p/610558#M177811</guid>
      <dc:creator>Utabikunda</dc:creator>
      <dc:date>2019-12-09T21:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Count combination of value instances across multiple by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-combination-of-value-instances-across-multiple-by-groups/m-p/610586#M177821</link>
      <description>&lt;P&gt;First.id is not true (=1) when this is not a new id. You only need first.group :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set test;
by id group;
if first.group 
	then enroll_ord = 1; 
 	else enroll_ord + 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Dec 2019 23:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-combination-of-value-instances-across-multiple-by-groups/m-p/610586#M177821</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-12-09T23:20:44Z</dc:date>
    </item>
  </channel>
</rss>

