<?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 ids with two or more observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/count-ids-with-two-or-more-observation/m-p/348720#M80776</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Post test data in the form of a datastep!&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just a rough guess:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select ID,
           DRUG
           count(*) as RES
  from   HAVE
  group by ID,DRUG
  having RES &amp;gt;= 2;
quit;&lt;/PRE&gt;</description>
    <pubDate>Mon, 10 Apr 2017 14:33:35 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-04-10T14:33:35Z</dc:date>
    <item>
      <title>count ids with two or more observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-ids-with-two-or-more-observation/m-p/348712#M80772</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;id   drug 
1    a
1   a
1   a
1  b
1  c
1 c
2 a
2 b
2 b
2 b
2 c
2 c&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have the following data. I want to create an output that provide me with the total number of id who have 2 or more of a specific drug. For example for id1: count the id one for a, none for b, and one for c&lt;/P&gt;&lt;P&gt;here is the output I am looking for&lt;/P&gt;&lt;P&gt;drug &amp;nbsp;total ids&lt;/P&gt;&lt;P&gt;a &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;b &amp;nbsp;1&lt;/P&gt;&lt;P&gt;c &amp;nbsp;2&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 14:17:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-ids-with-two-or-more-observation/m-p/348712#M80772</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2017-04-10T14:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: count ids with two or more observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-ids-with-two-or-more-observation/m-p/348720#M80776</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Post test data in the form of a datastep!&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just a rough guess:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select ID,
           DRUG
           count(*) as RES
  from   HAVE
  group by ID,DRUG
  having RES &amp;gt;= 2;
quit;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 14:33:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-ids-with-two-or-more-observation/m-p/348720#M80776</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-04-10T14:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: count ids with two or more observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-ids-with-two-or-more-observation/m-p/348730#M80780</link>
      <description>&lt;P&gt;If you know how to read PROC FREQ output, two PROC FREQs should do the job nicely.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;tables drug * id / noprint out=counts;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=counts;&lt;/P&gt;
&lt;P&gt;tables drug;&lt;/P&gt;
&lt;P&gt;where count &amp;gt; 1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output data set from the first PROC FREQ counts the number of observations for each DRUG / ID combination.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The report from the second PROC FREQ will give you a list of the drugs, and the FREQUENCY column is the number of IDs.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 14:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-ids-with-two-or-more-observation/m-p/348730#M80780</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-10T14:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: count ids with two or more observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-ids-with-two-or-more-observation/m-p/348734#M80782</link>
      <description>proc sql;&lt;BR /&gt;select drug, count(*) from&lt;BR /&gt;(select id,drug,count(*) as total from have group by id,drug having calculated total ge 2)&lt;BR /&gt;group by drug;&lt;BR /&gt;quit;</description>
      <pubDate>Mon, 10 Apr 2017 15:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-ids-with-two-or-more-observation/m-p/348734#M80782</guid>
      <dc:creator>lakshmi_74</dc:creator>
      <dc:date>2017-04-10T15:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: count ids with two or more observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-ids-with-two-or-more-observation/m-p/348776#M80797</link>
      <description>&lt;P&gt;Thank you all!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 16:28:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-ids-with-two-or-more-observation/m-p/348776#M80797</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2017-04-10T16:28:19Z</dc:date>
    </item>
  </channel>
</rss>

