<?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 Counting with Condition #2 in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Counting-with-Condition-2/m-p/561327#M10571</link>
    <description>&lt;P&gt;Dear SAS community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: My Apologies, I have amended the question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is yet another counting with the condition that I have been struggling with. Please help!&lt;/P&gt;&lt;P&gt;Your help would be much appreciated.&lt;/P&gt;&lt;P&gt;Suppose that I have data below;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Subject / Year / Condition&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A 1991 1&lt;/P&gt;&lt;P&gt;A 1992 1&lt;/P&gt;&lt;P&gt;A 1993 2&lt;/P&gt;&lt;P&gt;A 1994 2&lt;/P&gt;&lt;P&gt;A 1995 3&lt;/P&gt;&lt;P&gt;A 1996 1&lt;/P&gt;&lt;P&gt;A 1997 1&lt;/P&gt;&lt;P&gt;B 1991 2&lt;/P&gt;&lt;P&gt;B 1992 1&lt;/P&gt;&lt;P&gt;B 1993 2&lt;/P&gt;&lt;P&gt;B 1994 1&lt;/P&gt;&lt;P&gt;B 1995 3&lt;/P&gt;&lt;P&gt;B 1996 1&lt;/P&gt;&lt;P&gt;B 1997 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot change the order of this, and I would like to start counting&lt;/P&gt;&lt;P&gt;when "1" appears and continue counting without counting '2' or '3' so that I get&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Subject / Year / Condition / Count&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A 1991 1&amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;A 1992 1&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;A 1993 2&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;A 1994 2&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;A 1995 3&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;A 1996 1&amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;A 1997 1&amp;nbsp; &amp;nbsp; 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;B 1991 2&amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;B 1992 1&amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;B 1993 2&amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;B 1994 1&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;B 1995 3&amp;nbsp; &amp;nbsp; 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;B 1996 1&amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;B 1997 2&amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I achieve this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically the end goal is to then find the number of each 1, 2, 3 and find the percentage of them to select which one I would choose based on the highest probability. But I will need to find a solution to this first.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;T&lt;/P&gt;</description>
    <pubDate>Fri, 24 May 2019 07:39:40 GMT</pubDate>
    <dc:creator>tonoplast</dc:creator>
    <dc:date>2019-05-24T07:39:40Z</dc:date>
    <item>
      <title>Counting with Condition #2</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-with-Condition-2/m-p/561327#M10571</link>
      <description>&lt;P&gt;Dear SAS community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: My Apologies, I have amended the question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is yet another counting with the condition that I have been struggling with. Please help!&lt;/P&gt;&lt;P&gt;Your help would be much appreciated.&lt;/P&gt;&lt;P&gt;Suppose that I have data below;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Subject / Year / Condition&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A 1991 1&lt;/P&gt;&lt;P&gt;A 1992 1&lt;/P&gt;&lt;P&gt;A 1993 2&lt;/P&gt;&lt;P&gt;A 1994 2&lt;/P&gt;&lt;P&gt;A 1995 3&lt;/P&gt;&lt;P&gt;A 1996 1&lt;/P&gt;&lt;P&gt;A 1997 1&lt;/P&gt;&lt;P&gt;B 1991 2&lt;/P&gt;&lt;P&gt;B 1992 1&lt;/P&gt;&lt;P&gt;B 1993 2&lt;/P&gt;&lt;P&gt;B 1994 1&lt;/P&gt;&lt;P&gt;B 1995 3&lt;/P&gt;&lt;P&gt;B 1996 1&lt;/P&gt;&lt;P&gt;B 1997 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot change the order of this, and I would like to start counting&lt;/P&gt;&lt;P&gt;when "1" appears and continue counting without counting '2' or '3' so that I get&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Subject / Year / Condition / Count&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A 1991 1&amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;A 1992 1&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;A 1993 2&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;A 1994 2&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;A 1995 3&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;A 1996 1&amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;A 1997 1&amp;nbsp; &amp;nbsp; 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;B 1991 2&amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;B 1992 1&amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;B 1993 2&amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;B 1994 1&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;B 1995 3&amp;nbsp; &amp;nbsp; 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;B 1996 1&amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;B 1997 2&amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I achieve this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically the end goal is to then find the number of each 1, 2, 3 and find the percentage of them to select which one I would choose based on the highest probability. But I will need to find a solution to this first.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;T&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2019 07:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-with-Condition-2/m-p/561327#M10571</guid>
      <dc:creator>tonoplast</dc:creator>
      <dc:date>2019-05-24T07:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Counting with Condition #2</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-with-Condition-2/m-p/561328#M10572</link>
      <description>&lt;P&gt;Why do you not count the last 1?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Subject $ Year Condition;
datalines;
A 1991 1
A 1992 1
A 1993 2
A 1994 2
A 1995 3
A 1996 1
A 1997 1
;

data want;
   set have;
   if Condition=1 then Count+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 May 2019 07:32:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-with-Condition-2/m-p/561328#M10572</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-24T07:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: Counting with Condition #2</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-with-Condition-2/m-p/561332#M10573</link>
      <description>&lt;P&gt;The expected result seems to require resetting count when "subject" changes. Right? This requires sorted or at least properly grouped data. This is an extended version of &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt; code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   by Subject notsorted;
   if first.Subject then Count=0;
   if Condition=1 then Count+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 May 2019 08:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-with-Condition-2/m-p/561332#M10573</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-05-24T08:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Counting with Condition #2</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Counting-with-Condition-2/m-p/561333#M10574</link>
      <description>&lt;P&gt;Thank you! Yes, this is correct. It was so simple and I was trying such complicated things. Have a good weekend!&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2019 08:10:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Counting-with-Condition-2/m-p/561333#M10574</guid>
      <dc:creator>tonoplast</dc:creator>
      <dc:date>2019-05-24T08:10:15Z</dc:date>
    </item>
  </channel>
</rss>

