<?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: how to find the missing records from the starndard list in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549938#M152656</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 

data have;
input state $ drug_code;
datalines;
AL 1
AL 2
AL 3
AL 4
GA 2
GA 3
GA 4
GA 5
;
run;

data drug_code;
input drug_code;
datalines;
1
2
3
4
5
;
run;
proc sql;
create table want as
select a.*
 from 
(
select * from
(select distinct state from have),(select distinct drug_code from drug_code)
) as a left join have as b on a.state=b.state and a.drug_code=b.drug_code
where b.drug_code is missing;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 10 Apr 2019 13:07:12 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2019-04-10T13:07:12Z</dc:date>
    <item>
      <title>how to find the missing records from the starndard list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549781#M152603</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset with two variables: State and drug code. I want to print out a list of state who missed drug codes from the standard drug code list. the data set is list this:&lt;/P&gt;
&lt;P&gt;state&amp;nbsp;&amp;nbsp; drug_code&lt;/P&gt;
&lt;P&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;
&lt;P&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;
&lt;P&gt;GA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;GA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;
&lt;P&gt;GA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;
&lt;P&gt;GA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;..&lt;/P&gt;
&lt;P&gt;and the standard drug_code looks like this:&lt;/P&gt;
&lt;P&gt;drug_code&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;P&gt;4&lt;/P&gt;
&lt;P&gt;5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so the final result will looks like this:&lt;/P&gt;
&lt;P&gt;State &amp;nbsp;missing_drug_code&lt;/P&gt;
&lt;P&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;GA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;not sure how to write a sas code to get the result.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 19:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549781#M152603</guid>
      <dc:creator>juliajulia</dc:creator>
      <dc:date>2019-04-09T19:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the missing records from the starndard list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549784#M152605</link>
      <description>&lt;P&gt;Assuming your input data set is called have and your data is as shown, this would give you that list. This assumes that the list includes all states and at least one entry for every drug code. If the later is not true then this will not work, but there are other approach. CLASSDATA and PRELOADFMT are two options as is a standard merge.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
table state*drug_code / out=want(where=(count=0)) sparse;
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/16488"&gt;@juliajulia&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset with two variables: State and drug code. I want to print out a list of state who missed drug codes from the standard drug code list. the data set is list this:&lt;/P&gt;
&lt;P&gt;state&amp;nbsp;&amp;nbsp; drug_code&lt;/P&gt;
&lt;P&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;
&lt;P&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;
&lt;P&gt;GA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;GA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;
&lt;P&gt;GA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;
&lt;P&gt;GA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;..&lt;/P&gt;
&lt;P&gt;and the standard drug_code looks like this:&lt;/P&gt;
&lt;P&gt;drug_code&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;P&gt;4&lt;/P&gt;
&lt;P&gt;5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so the final result will looks like this:&lt;/P&gt;
&lt;P&gt;State &amp;nbsp;missing_drug_code&lt;/P&gt;
&lt;P&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;GA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;not sure how to write a sas code to get the result.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 19:47:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549784#M152605</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-04-09T19:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the missing records from the starndard list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549786#M152607</link>
      <description>&lt;P&gt;my standard drug list table does not have the state variable, it only have the drug_code in there.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 19:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549786#M152607</guid>
      <dc:creator>juliajulia</dc:creator>
      <dc:date>2019-04-09T19:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the missing records from the starndard list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549789#M152608</link>
      <description>So you don't have that first table shown? The PROC FREQ approach doesn't need a lookup table, if you can make those assumptions I mentioned initially. Did you try the code?</description>
      <pubDate>Tue, 09 Apr 2019 19:55:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549789#M152608</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-04-09T19:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the missing records from the starndard list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549804#M152610</link>
      <description>&lt;P&gt;yes, I tried the code. but it only can show the drug_code that already have in the table.&amp;nbsp;there are&amp;nbsp;some drug codes are not in the first table. for example, the code 6 and 7 are not in the dataset have.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; state $ drug_code;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AL 1&lt;/P&gt;
&lt;P&gt;AL 2&lt;/P&gt;
&lt;P&gt;AL 3&lt;/P&gt;
&lt;P&gt;AL 4&lt;/P&gt;
&lt;P&gt;GA 2&lt;/P&gt;
&lt;P&gt;GA 3&lt;/P&gt;
&lt;P&gt;GA 4&lt;/P&gt;
&lt;P&gt;GA 5&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;run&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; drug_code;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; drugcode;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;P&gt;4&lt;/P&gt;
&lt;P&gt;5&lt;/P&gt;
&lt;P&gt;6&lt;/P&gt;
&lt;P&gt;7&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;run&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;freq&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; state*drug_code / &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=want(where=(count=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;)) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;sparse&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;I want the result like this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;State&amp;nbsp; Missing_code&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;AL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;GA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;GA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;GA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/FONT&gt;&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;</description>
      <pubDate>Tue, 09 Apr 2019 20:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549804#M152610</guid>
      <dc:creator>juliajulia</dc:creator>
      <dc:date>2019-04-09T20:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the missing records from the starndard list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549938#M152656</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 

data have;
input state $ drug_code;
datalines;
AL 1
AL 2
AL 3
AL 4
GA 2
GA 3
GA 4
GA 5
;
run;

data drug_code;
input drug_code;
datalines;
1
2
3
4
5
;
run;
proc sql;
create table want as
select a.*
 from 
(
select * from
(select distinct state from have),(select distinct drug_code from drug_code)
) as a left join have as b on a.state=b.state and a.drug_code=b.drug_code
where b.drug_code is missing;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Apr 2019 13:07:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549938#M152656</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-04-10T13:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the missing records from the starndard list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549939#M152657</link>
      <description>&lt;P&gt;OR this one .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 

data have;
input state $ drug_code;
datalines;
AL 1
AL 2
AL 3
AL 4
GA 2
GA 3
GA 4
GA 5
;
run;

data drug_code;
input drug_code;
datalines;
1
2
3
4
5
;
run;
proc sql;
create table want as
select * from
(select distinct state from have),(select distinct drug_code from drug_code)
except
select * from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Apr 2019 13:09:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549939#M152657</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-04-10T13:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the missing records from the starndard list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549984#M152673</link>
      <description>&lt;P&gt;this code works perfectly. thank you for your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Julia&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 14:58:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-missing-records-from-the-starndard-list/m-p/549984#M152673</guid>
      <dc:creator>juliajulia</dc:creator>
      <dc:date>2019-04-10T14:58:36Z</dc:date>
    </item>
  </channel>
</rss>

