<?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: Getting counts in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Getting-counts/m-p/557967#M155629</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240770"&gt;@Ranjeeta&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; Non_QBP_PBF_STROKE (keep = HEM_NONQBP ISC_NONQBP HEM_QBP ISC_QBP INDEX_ACUTE);&lt;/P&gt;
&lt;P&gt;set pbf_stroke;&lt;/P&gt;
&lt;P&gt;If&amp;nbsp; sum(of HEM_NONQBP ISC_NONQBP) =&lt;STRONG&gt;1&lt;/STRONG&gt; and INDEX_ACUTE=&lt;STRONG&gt;1&lt;/STRONG&gt; and sum(of HEM_QBP ISC_QBP)=&lt;STRONG&gt;0&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would I write the above step correctly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to get the count of all cases where either HEM_NONQBP or ISC_NONQBP=1 and index-acute=1 and HEM_QBP or ISC_QBP should be 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If&amp;nbsp; sum(of HEM_NONQBP ISC_NONQBP) =&lt;STRONG&gt;1&lt;/STRONG&gt; is FALSE when both of&amp;nbsp;HEM_NONQBP&amp;nbsp; ISC_NONQBP are = 1.&lt;/P&gt;
&lt;P&gt;If the variables are 0/1 coded perhaps you want&lt;/P&gt;
&lt;P&gt;if max( of HEM_NONQBP ISC_NONQBP) =&lt;STRONG&gt;1)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;similar sum(of HEM_QBP ISC_QBP)=0 is not true when either is 1 and the other 0. If the variables actually have more values than 0/1 you have a potential very large number of ways to the sum to be zero when neither of the variables is 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are all of the possible combinations of your variables &lt;STRONG&gt;if they are all coded 0/1&lt;/STRONG&gt;. Indicate which of these are the ones you want to keep. Either mark the Result column with an x or provide the obs numbers.&lt;/P&gt;
&lt;PRE&gt;        HEM_      ISC_     INDEX_
Obs    NONQBP    NONQBP     ACUTE    HEM_QBP    ISC_QBP    result

  1       0         0         0         0          0
  2       0         0         0         0          1
  3       0         0         0         1          0
  4       0         0         0         1          1
  5       0         0         1         0          0
  6       0         0         1         0          1
  7       0         0         1         1          0
  8       0         0         1         1          1
  9       0         1         0         0          0
 10       0         1         0         0          1
 11       0         1         0         1          0
 12       0         1         0         1          1
 13       0         1         1         0          0
 14       0         1         1         0          1
 15       0         1         1         1          0
 16       0         1         1         1          1
 17       1         0         0         0          0
 18       1         0         0         0          1
 19       1         0         0         1          0
 20       1         0         0         1          1
 21       1         0         1         0          0
 22       1         0         1         0          1
 23       1         0         1         1          0
 24       1         0         1         1          1
 25       1         1         0         0          0
 26       1         1         0         0          1
 27       1         1         0         1          0
 28       1         1         0         1          1
 29       1         1         1         0          0
 30       1         1         1         0          1
 31       1         1         1         1          0
 32       1         1         1         1          1
&lt;/PRE&gt;
&lt;P&gt;If the variables are coded other than 0/1 you'll have to provide example data as your problem using SUM with or instead of possibly MAX&amp;nbsp;or MIN has a very large possible set of solutions.&lt;/P&gt;</description>
    <pubDate>Fri, 10 May 2019 20:44:28 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-05-10T20:44:28Z</dc:date>
    <item>
      <title>Getting counts</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-counts/m-p/557811#M155553</link>
      <description>&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; Non_QBP_PBF_STROKE (keep = HEM_NONQBP ISC_NONQBP HEM_QBP ISC_QBP INDEX_ACUTE);&lt;/P&gt;&lt;P&gt;set pbf_stroke;&lt;/P&gt;&lt;P&gt;If&amp;nbsp; sum(of HEM_NONQBP ISC_NONQBP) =&lt;STRONG&gt;1&lt;/STRONG&gt; and INDEX_ACUTE=&lt;STRONG&gt;1&lt;/STRONG&gt; and sum(of HEM_QBP ISC_QBP)=&lt;STRONG&gt;0&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I write the above step correctly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to get the count of all cases where either HEM_NONQBP or ISC_NONQBP=1 and index-acute=1 and HEM_QBP or ISC_QBP should be 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2019 15:05:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-counts/m-p/557811#M155553</guid>
      <dc:creator>Ranjeeta</dc:creator>
      <dc:date>2019-05-10T15:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: Getting counts</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-counts/m-p/557817#M155558</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;If  sum(HEM_NONQBP, ISC_NONQBP) &amp;gt;=1 and INDEX_ACUTE=1 and  (HEM_QBP=0 or ISC_QBP=0);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 May 2019 15:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-counts/m-p/557817#M155558</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-05-10T15:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: Getting counts</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-counts/m-p/557834#M155569</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240770"&gt;@Ranjeeta&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a difference between your logic and the description of what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your logic (with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;'s corrections)&amp;nbsp; says that&amp;nbsp;&lt;SPAN&gt;HEM_QBP&amp;nbsp; and ISC_QBP should both be 0, but your description says that either&amp;nbsp; HEM_QBP or ISC_QBP should be 0.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2019 15:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-counts/m-p/557834#M155569</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-05-10T15:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Getting counts</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-counts/m-p/557967#M155629</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240770"&gt;@Ranjeeta&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; Non_QBP_PBF_STROKE (keep = HEM_NONQBP ISC_NONQBP HEM_QBP ISC_QBP INDEX_ACUTE);&lt;/P&gt;
&lt;P&gt;set pbf_stroke;&lt;/P&gt;
&lt;P&gt;If&amp;nbsp; sum(of HEM_NONQBP ISC_NONQBP) =&lt;STRONG&gt;1&lt;/STRONG&gt; and INDEX_ACUTE=&lt;STRONG&gt;1&lt;/STRONG&gt; and sum(of HEM_QBP ISC_QBP)=&lt;STRONG&gt;0&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would I write the above step correctly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to get the count of all cases where either HEM_NONQBP or ISC_NONQBP=1 and index-acute=1 and HEM_QBP or ISC_QBP should be 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If&amp;nbsp; sum(of HEM_NONQBP ISC_NONQBP) =&lt;STRONG&gt;1&lt;/STRONG&gt; is FALSE when both of&amp;nbsp;HEM_NONQBP&amp;nbsp; ISC_NONQBP are = 1.&lt;/P&gt;
&lt;P&gt;If the variables are 0/1 coded perhaps you want&lt;/P&gt;
&lt;P&gt;if max( of HEM_NONQBP ISC_NONQBP) =&lt;STRONG&gt;1)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;similar sum(of HEM_QBP ISC_QBP)=0 is not true when either is 1 and the other 0. If the variables actually have more values than 0/1 you have a potential very large number of ways to the sum to be zero when neither of the variables is 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are all of the possible combinations of your variables &lt;STRONG&gt;if they are all coded 0/1&lt;/STRONG&gt;. Indicate which of these are the ones you want to keep. Either mark the Result column with an x or provide the obs numbers.&lt;/P&gt;
&lt;PRE&gt;        HEM_      ISC_     INDEX_
Obs    NONQBP    NONQBP     ACUTE    HEM_QBP    ISC_QBP    result

  1       0         0         0         0          0
  2       0         0         0         0          1
  3       0         0         0         1          0
  4       0         0         0         1          1
  5       0         0         1         0          0
  6       0         0         1         0          1
  7       0         0         1         1          0
  8       0         0         1         1          1
  9       0         1         0         0          0
 10       0         1         0         0          1
 11       0         1         0         1          0
 12       0         1         0         1          1
 13       0         1         1         0          0
 14       0         1         1         0          1
 15       0         1         1         1          0
 16       0         1         1         1          1
 17       1         0         0         0          0
 18       1         0         0         0          1
 19       1         0         0         1          0
 20       1         0         0         1          1
 21       1         0         1         0          0
 22       1         0         1         0          1
 23       1         0         1         1          0
 24       1         0         1         1          1
 25       1         1         0         0          0
 26       1         1         0         0          1
 27       1         1         0         1          0
 28       1         1         0         1          1
 29       1         1         1         0          0
 30       1         1         1         0          1
 31       1         1         1         1          0
 32       1         1         1         1          1
&lt;/PRE&gt;
&lt;P&gt;If the variables are coded other than 0/1 you'll have to provide example data as your problem using SUM with or instead of possibly MAX&amp;nbsp;or MIN has a very large possible set of solutions.&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2019 20:44:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-counts/m-p/557967#M155629</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-10T20:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: Getting counts</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-counts/m-p/558067#M155697</link>
      <description>&lt;P&gt;You can use the same filter condition in SQL or a WHERE statement if needed.&lt;/P&gt;
&lt;P&gt;I assumed that hem_qbp = 1 and hem_nonqbp are complementatry, when one of the variables is a 1, the other will be 0. It doesn't really matter if that's true though, the condition should work the same. Note that | is an OR operator and this works assuming your variables are all binary. If it's 1/2 then it may be different.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Fake data;
data have;
    call streaminit(100);

    do i=1 to 1000;
        hem_qbp=rand('bernoulli', 0.4);
        hem_nonqbp=not hem_qbp;
        isc_nonqbp=rand('bernoulli', 0.6);
        index_acute=rand('bernoulli', 0.1);
        isc_qbp=not isc_nonqbp;
        output;
    end;
run;

*filter based on conditions;
data want;
    set have;

    IF index_acute=1 and (hem_nonqbp | isc_nonqbp) and (hem_qbp | isc_qbp);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240770"&gt;@Ranjeeta&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; Non_QBP_PBF_STROKE (keep = HEM_NONQBP ISC_NONQBP HEM_QBP ISC_QBP INDEX_ACUTE);&lt;/P&gt;
&lt;P&gt;set pbf_stroke;&lt;/P&gt;
&lt;P&gt;If&amp;nbsp; sum(of HEM_NONQBP ISC_NONQBP) =&lt;STRONG&gt;1&lt;/STRONG&gt; and INDEX_ACUTE=&lt;STRONG&gt;1&lt;/STRONG&gt; and sum(of HEM_QBP ISC_QBP)=&lt;STRONG&gt;0&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would I write the above step correctly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to get the count of all cases where either HEM_NONQBP or ISC_NONQBP=1 and index-acute=1 and HEM_QBP or ISC_QBP should be 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 May 2019 18:49:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-counts/m-p/558067#M155697</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-11T18:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Getting counts</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-counts/m-p/558711#M155952</link>
      <description>Thankyo for all your support I have a result i need nw will post an update and look at the proposed solution to learn more</description>
      <pubDate>Tue, 14 May 2019 17:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-counts/m-p/558711#M155952</guid>
      <dc:creator>Ranjeeta</dc:creator>
      <dc:date>2019-05-14T17:43:13Z</dc:date>
    </item>
  </channel>
</rss>

