<?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 of IDs by a combination of fields in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715448#M220976</link>
    <description>&lt;P&gt;&lt;SPAN&gt;could you try this code and share the output:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
set have;
if case_id="." then case_id="";
run;

proc sql;create table want as
select Location, 
	   count(distinct Store) as unique_stores,
	   count(distinct Case_ID) as not_missing_id, 
	   count(distinct Case_ID)/count(distinct Store) as cmplt_id format=percent7.
from have
group by Location;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 29 Jan 2021 20:00:56 GMT</pubDate>
    <dc:creator>Angel_Larrion</dc:creator>
    <dc:date>2021-01-29T20:00:56Z</dc:date>
    <item>
      <title>Count of IDs by a combination of fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715315#M220928</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to use the below data to count the number of non-missing IDs. The goal is to reach the percentage completion for each region:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Location&lt;/TD&gt;&lt;TD&gt;Store&lt;/TD&gt;&lt;TD&gt;Case_ID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;East&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Case1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;East&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lt;TD&gt;100%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;West&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;50%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;South&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;100%&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you everyone.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 15:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715315#M220928</guid>
      <dc:creator>altijani</dc:creator>
      <dc:date>2021-01-29T15:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Count of IDs by a combination of fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715376#M220952</link>
      <description>&lt;P&gt;You can obtain that with a proc sql:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;&lt;BR /&gt;create table want as
select Location, 
	   count(distinct Store) as unique_stores,
	   count(distinct Case_ID) as not_missing_id, 
	   count(distinct Case_ID)/count(distinct Store) as cmplt_id format=percent7.
from have
group by Location;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 17:07:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715376#M220952</guid>
      <dc:creator>Angel_Larrion</dc:creator>
      <dc:date>2021-01-29T17:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: Count of IDs by a combination of fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715378#M220953</link>
      <description>The count function ignores missing values, and the distinct option counts unique values.</description>
      <pubDate>Fri, 29 Jan 2021 17:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715378#M220953</guid>
      <dc:creator>Angel_Larrion</dc:creator>
      <dc:date>2021-01-29T17:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Count of IDs by a combination of fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715426#M220973</link>
      <description>&lt;P&gt;Hi. Thanks, but this code does not provide the results I am looking for. It provides instead this results as 1, 1, 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for&lt;/P&gt;&lt;P&gt;1. the total number of stores in each region&lt;/P&gt;&lt;P&gt;2. For those stores, how many of them have completed (non missing) IDs?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 19:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715426#M220973</guid>
      <dc:creator>altijani</dc:creator>
      <dc:date>2021-01-29T19:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Count of IDs by a combination of fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715429#M220974</link>
      <description>&lt;P&gt;i ran that code and this is the output table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Angel_Larrion_0-1611949407165.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54121i710600046778DFA0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Angel_Larrion_0-1611949407165.png" alt="Angel_Larrion_0-1611949407165.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;in the Case_id column do you have dots or missing values (i.e. space blank)?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 19:47:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715429#M220974</guid>
      <dc:creator>Angel_Larrion</dc:creator>
      <dc:date>2021-01-29T19:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: Count of IDs by a combination of fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715430#M220975</link>
      <description>&lt;P&gt;Yes. Many.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 19:49:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715430#M220975</guid>
      <dc:creator>altijani</dc:creator>
      <dc:date>2021-01-29T19:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: Count of IDs by a combination of fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715448#M220976</link>
      <description>&lt;P&gt;&lt;SPAN&gt;could you try this code and share the output:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
set have;
if case_id="." then case_id="";
run;

proc sql;create table want as
select Location, 
	   count(distinct Store) as unique_stores,
	   count(distinct Case_ID) as not_missing_id, 
	   count(distinct Case_ID)/count(distinct Store) as cmplt_id format=percent7.
from have
group by Location;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Jan 2021 20:00:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-of-IDs-by-a-combination-of-fields/m-p/715448#M220976</guid>
      <dc:creator>Angel_Larrion</dc:creator>
      <dc:date>2021-01-29T20:00:56Z</dc:date>
    </item>
  </channel>
</rss>

