<?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: Need codes for each primary key id in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-codes-for-each-primary-key-id/m-p/675401#M203498</link>
    <description>&lt;P&gt;This is one of those cases where it's easier if you reverse your logic&lt;/P&gt;
&lt;P&gt;1. Find IDs that have something other than those two values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Exclude those IDs&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select * 
from have 
where primaryKey not in 
         ( select distinct PrimaryKey 
            from have 
            where proc_code not in ('A2391', 'A2392')
          );
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@anonymous_user&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to only pick those primary keys with a code equal to A2391 AND A2392 ONLY - for each primarykey.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PrimaryKey &amp;nbsp; &amp;nbsp;Proc Code&lt;/P&gt;
&lt;P&gt;a156273. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;
&lt;P&gt;a156273. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;
&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;
&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;
&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2393&lt;/P&gt;
&lt;P&gt;b784734. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;
&lt;P&gt;b784734. &amp;nbsp; &amp;nbsp; A2392&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should look like this&lt;/P&gt;
&lt;P&gt;a156273. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;
&lt;P&gt;a156273. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;
&lt;P&gt;b784734. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;
&lt;P&gt;b784734. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;
&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;
&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So for each primary key, I want to bring in only those who have those codes.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 08 Aug 2020 16:13:21 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-08-08T16:13:21Z</dc:date>
    <item>
      <title>Need codes for each primary key id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-codes-for-each-primary-key-id/m-p/675395#M203496</link>
      <description>&lt;P&gt;I'm trying to only pick those primary keys with a code equal to A2391 AND A2392 ONLY - for each primarykey.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PrimaryKey &amp;nbsp; &amp;nbsp;Proc Code&lt;/P&gt;&lt;P&gt;a156273. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;&lt;P&gt;a156273. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2393&lt;/P&gt;&lt;P&gt;b784734. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;&lt;P&gt;b784734. &amp;nbsp; &amp;nbsp; A2392&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Should look like this&lt;/P&gt;&lt;P&gt;a156273. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;&lt;P&gt;a156273. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;&lt;P&gt;b784734. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;&lt;P&gt;b784734. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for each primary key, I want to bring in only those who have those codes.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Aug 2020 15:27:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-codes-for-each-primary-key-id/m-p/675395#M203496</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2020-08-08T15:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Need codes for each primary key id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-codes-for-each-primary-key-id/m-p/675401#M203498</link>
      <description>&lt;P&gt;This is one of those cases where it's easier if you reverse your logic&lt;/P&gt;
&lt;P&gt;1. Find IDs that have something other than those two values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Exclude those IDs&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select * 
from have 
where primaryKey not in 
         ( select distinct PrimaryKey 
            from have 
            where proc_code not in ('A2391', 'A2392')
          );
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@anonymous_user&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to only pick those primary keys with a code equal to A2391 AND A2392 ONLY - for each primarykey.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PrimaryKey &amp;nbsp; &amp;nbsp;Proc Code&lt;/P&gt;
&lt;P&gt;a156273. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;
&lt;P&gt;a156273. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;
&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;
&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;
&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2393&lt;/P&gt;
&lt;P&gt;b784734. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;
&lt;P&gt;b784734. &amp;nbsp; &amp;nbsp; A2392&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should look like this&lt;/P&gt;
&lt;P&gt;a156273. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;
&lt;P&gt;a156273. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;
&lt;P&gt;b784734. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;
&lt;P&gt;b784734. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;
&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2391&lt;/P&gt;
&lt;P&gt;c456373. &amp;nbsp; &amp;nbsp; &amp;nbsp;A2392&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So for each primary key, I want to bring in only those who have those codes.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Aug 2020 16:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-codes-for-each-primary-key-id/m-p/675401#M203498</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-08T16:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Need codes for each primary key id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-codes-for-each-primary-key-id/m-p/675440#M203528</link>
      <description>&lt;P&gt;Thank you for your response.&lt;/P&gt;&lt;P&gt;I'm getting a syntax error - ERROR: 22-322: after where it says:&lt;/P&gt;&lt;P&gt;where PrimaryKey not in&lt;/P&gt;</description>
      <pubDate>Sat, 08 Aug 2020 22:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-codes-for-each-primary-key-id/m-p/675440#M203528</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2020-08-08T22:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need codes for each primary key id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-codes-for-each-primary-key-id/m-p/675445#M203529</link>
      <description>Post your exact code and log. I tested your code against the data provided and it works fine with no errors so there's either a typo or your data doesn't match what's shown. I'm assuming you changed the variable and table names to match your data.</description>
      <pubDate>Sat, 08 Aug 2020 23:53:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-codes-for-each-primary-key-id/m-p/675445#M203529</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-08T23:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Need codes for each primary key id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-codes-for-each-primary-key-id/m-p/675567#M203570</link>
      <description>&lt;P&gt;log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc Sql;&lt;/P&gt;&lt;P&gt;create table s.mergefinal as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from s.merge&lt;/P&gt;&lt;P&gt;where PrimaryKey not in&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: GROUP, HAVING, ORDER,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(select distinct PrimaryKey from merge&lt;/P&gt;&lt;P&gt;where proc_code not in ('2391','2392')&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 12:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-codes-for-each-primary-key-id/m-p/675567#M203570</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2020-08-10T12:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need codes for each primary key id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-codes-for-each-primary-key-id/m-p/675630#M203584</link>
      <description>That isn't your full code and log.</description>
      <pubDate>Mon, 10 Aug 2020 15:36:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-codes-for-each-primary-key-id/m-p/675630#M203584</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-10T15:36:26Z</dc:date>
    </item>
  </channel>
</rss>

