<?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: Missing Data Elements? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Missing-Data-Elements/m-p/595689#M171421</link>
    <description>&lt;P&gt;Create a data set which you know has all 7 keys for each ID. Then compare this created data set to the actual data set to see what isn't present in the actual data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create fake data set with all keys using Cartesian Join in PROC SQL */
proc sql;
    create table distinct_id as select distinct id from actual;
    create table distinct_key as select distinct key from actual;
    create table fake as select * from distinct_id,distinct_key;
quit;

/* Compare fake to actual */
data compared;
     merge fake actual(in=in2);
     by id key
     if not in2; /* This creates a data set compared of only those keys that are not in data set actual */
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 11 Oct 2019 12:06:37 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-10-11T12:06:37Z</dc:date>
    <item>
      <title>Missing Data Elements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-Data-Elements/m-p/595685#M171420</link>
      <description>&lt;P&gt;Good Morning All.&amp;nbsp; I have never come across something like this issue before so I am not sure how to search for the issue.&amp;nbsp; I am not sure what something like this would be called.&amp;nbsp; I appreciate any guidance on this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the issue is I have data that has an ID number and for each ID number there should be 7 keys associated.&amp;nbsp; See example below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;KEY&lt;/P&gt;
&lt;P&gt;00001&amp;nbsp; &amp;nbsp; 01&lt;/P&gt;
&lt;P&gt;00001&amp;nbsp; &amp;nbsp; 02&lt;/P&gt;
&lt;P&gt;00001&amp;nbsp; &amp;nbsp; 03&lt;/P&gt;
&lt;P&gt;00001&amp;nbsp; &amp;nbsp; 04&lt;/P&gt;
&lt;P&gt;00001&amp;nbsp; &amp;nbsp; 05&lt;/P&gt;
&lt;P&gt;00001&amp;nbsp; &amp;nbsp; 06&lt;/P&gt;
&lt;P&gt;00001&amp;nbsp; &amp;nbsp; 07&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However some data is coming through like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;KEY&lt;/P&gt;
&lt;P&gt;00001&amp;nbsp; &amp;nbsp; 01&lt;/P&gt;
&lt;P&gt;00001&amp;nbsp; &amp;nbsp; 02&lt;/P&gt;
&lt;P&gt;00001&amp;nbsp; &amp;nbsp; 04&lt;/P&gt;
&lt;P&gt;00001&amp;nbsp; &amp;nbsp; 07&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I identify within SAS IDs that do not have the full 7 keys associated?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again thank you for any help or guidance.&amp;nbsp; I did have the idea of adding a row number count, so I will be trying that.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 12:05:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-Data-Elements/m-p/595685#M171420</guid>
      <dc:creator>IgawaKei29</dc:creator>
      <dc:date>2019-10-11T12:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Missing Data Elements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-Data-Elements/m-p/595689#M171421</link>
      <description>&lt;P&gt;Create a data set which you know has all 7 keys for each ID. Then compare this created data set to the actual data set to see what isn't present in the actual data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create fake data set with all keys using Cartesian Join in PROC SQL */
proc sql;
    create table distinct_id as select distinct id from actual;
    create table distinct_key as select distinct key from actual;
    create table fake as select * from distinct_id,distinct_key;
quit;

/* Compare fake to actual */
data compared;
     merge fake actual(in=in2);
     by id key
     if not in2; /* This creates a data set compared of only those keys that are not in data set actual */
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Oct 2019 12:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-Data-Elements/m-p/595689#M171421</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-10-11T12:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Missing Data Elements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-Data-Elements/m-p/595691#M171422</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input (ID         KEY) ($);
cards;
00001    01
00001    02
00001    03
00001    04
00001    05
00001    06
00001    07
00002    01
00002    02
00002    04
00002    07
;

proc sql;
create table check as
select *
from have
group by id
having count(distinct key)&amp;lt;7;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;/*Or if you want just a list of ID's that do not have 7 keys associated*/&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table check as
select distinct id
from have
group by id
having count(distinct key)&amp;lt;7;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 12:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-Data-Elements/m-p/595691#M171422</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-10-11T12:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Missing Data Elements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-Data-Elements/m-p/595697#M171423</link>
      <description>&lt;P&gt;Thank you both, appreciate the help.&amp;nbsp; Both options worked for what I needed.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 12:20:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-Data-Elements/m-p/595697#M171423</guid>
      <dc:creator>IgawaKei29</dc:creator>
      <dc:date>2019-10-11T12:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Missing Data Elements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-Data-Elements/m-p/595707#M171430</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Produce a dataset that is complete (all keys present!).&lt;/P&gt;
&lt;P&gt;Then check which of these keys are not present in your "real" dataset;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.all_keys;
LENGTH ID $ 5;
input ID $ 1-5;
cards;
00001
00002
;
run;
data work.all_keys;
 set work.all_keys;
 do key='01','02','03','04','05','06','07';
 output;
 end;
run;
proc sort data=work.all_keys; by ID key; run;
data work.real_keys;
LENGTH ID $ 5 key $ 2;
input ID $ 1-5 key $ 7-8;
cards;
00001 01
00001 02
00001 04
00001 07
00002 01
00002 02
00002 03
00002 04
00002 06
;
run;
proc sort data=work.real_keys; by ID key; run;
data missing_keys;
 merge work.all_keys(in=a) 
       work.real_keys(in=b); 
 by ID key;
 if a and NOT b then output;
run;
/* end of program */
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 12:41:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-Data-Elements/m-p/595707#M171430</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2019-10-11T12:41:50Z</dc:date>
    </item>
  </channel>
</rss>

