<?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: Removing observations during create table step in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/479608#M71483</link>
    <description>&lt;P&gt;I just found out that the variable I am using to select records, IDNum, is only unique by year. So I need to select cases based on unique instances of year and IDNum. I tried the following but it didn't work. Any suggestions?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE work.newobs as 
select * 
FROM newYTD_&amp;amp;FileDate 
where (IDnum not in (select IDnumber from old_&amp;amp;FileDate) and year not in (select year from Old&amp;amp;FileDate));
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 19 Jul 2018 17:53:46 GMT</pubDate>
    <dc:creator>MillerEL</dc:creator>
    <dc:date>2018-07-19T17:53:46Z</dc:date>
    <item>
      <title>Removing observations during create table step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/469726#M70809</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following code below which uses 2 files&amp;nbsp;to identify&amp;nbsp;which observations are new and which are old&amp;nbsp;by setting New=0 when the ID number is found in both files. Is it possible to delete all observations where New=0 in this procedure? I am trying to simplify my code, so I don't want to do it in a separate data step but I can't find syntax that works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;-EM&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    PROC SQL;
        CREATE TABLE work.newobs as select *, 
	    case
            WHEN IDnumber=IDnum then 0 /*old obs*/
            ELSE 1 end as New /*new obs*/
            FROM newYTD_&amp;amp;FileDate right join old_&amp;amp;FileDate
                on dc_number=cnumb;
    /*can we delete New=0 in this step?*/
    quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jun 2018 19:42:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/469726#M70809</guid>
      <dc:creator>MillerEL</dc:creator>
      <dc:date>2018-06-12T19:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations during create table step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/469729#M70810</link>
      <description>&lt;P&gt;perhaps&lt;/P&gt;
&lt;PRE&gt;PROC SQL;
        CREATE TABLE work.newobs as select *, 
	    case
            WHEN IDnumber=IDnum then 0 /*old obs*/
            ELSE 1 end as New /*new obs*/
            FROM newYTD_&amp;amp;FileDate right join old_&amp;amp;FileDate
                on dc_number=cnumb
         where calculated new=1
    ;
    quit;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jun 2018 19:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/469729#M70810</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-12T19:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations during create table step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/469733#M70811</link>
      <description>&lt;P&gt;It is not clear which column comes from which table in your query. You could use something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE work.newobs as 
select * 
FROM newYTD_&amp;amp;FileDate 
where IDnum not in (select IDnumber from old_&amp;amp;FileDate);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jun 2018 19:52:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/469733#M70811</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-06-12T19:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations during create table step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/469734#M70812</link>
      <description>&lt;P&gt;returned only one blank observation...&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 19:52:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/469734#M70812</guid>
      <dc:creator>MillerEL</dc:creator>
      <dc:date>2018-06-12T19:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations during create table step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/469758#M70817</link>
      <description>&lt;PRE&gt;PROC SQL;
        CREATE TABLE work.newobs as select *, 
	    case
            WHEN IDnumber=IDnum then 0 /*old obs*/
            ELSE 1 end as New /*new obs*/
            FROM newYTD_&amp;amp;FileDate right join old_&amp;amp;FileDate
                on dc_number=cnumb
         where &lt;CODE class=" language-sas"&gt;IDnumber&amp;lt;&amp;gt;IDnum&lt;BR /&gt;&lt;/CODE&gt;; &lt;BR /&gt;quit;&lt;/PRE&gt;
&lt;P&gt;Use the same condition you used for the CASE expression in the where clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was wondering why&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;solution didn't work. Do you have same data types or sometimes leading and trailing blanks maybe and issue.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 20:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/469758#M70817</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-06-12T20:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations during create table step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/469760#M70818</link>
      <description>&lt;P&gt;This worked great! Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 20:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/469760#M70818</guid>
      <dc:creator>MillerEL</dc:creator>
      <dc:date>2018-06-12T20:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations during create table step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/469771#M70820</link>
      <description>&lt;P&gt;Why would you want to do that using SQL code instead of DATA step?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data newobs  ;
  merge 
    old_&amp;amp;FileDate(in=inold rename=(cnumb=dc_number))
    newYTD_&amp;amp;FileDate(in=innew)
  ;
  by dc_number ;
  if inold and innew ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jun 2018 21:55:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/469771#M70820</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-12T21:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations during create table step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/479608#M71483</link>
      <description>&lt;P&gt;I just found out that the variable I am using to select records, IDNum, is only unique by year. So I need to select cases based on unique instances of year and IDNum. I tried the following but it didn't work. Any suggestions?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE work.newobs as 
select * 
FROM newYTD_&amp;amp;FileDate 
where (IDnum not in (select IDnumber from old_&amp;amp;FileDate) and year not in (select year from Old&amp;amp;FileDate));
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jul 2018 17:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/479608#M71483</guid>
      <dc:creator>MillerEL</dc:creator>
      <dc:date>2018-07-19T17:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations during create table step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/479615#M71486</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE work.newobs as 
select * 
FROM newYTD_&amp;amp;FileDate as a
where IDnum not in (select IDnumber from old_&amp;amp;FileDate where year=a.year);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jul 2018 18:03:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/479615#M71486</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-07-19T18:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations during create table step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/479616#M71487</link>
      <description>&lt;P&gt;This approach merges the files. I want to get rid of records in the new file that exist in the old file (I'm trying to remove records that I have already processed).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 18:04:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/479616#M71487</guid>
      <dc:creator>MillerEL</dc:creator>
      <dc:date>2018-07-19T18:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations during create table step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/479617#M71488</link>
      <description>&lt;P&gt;Can't get this to work. Other thoughts?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 20:34:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Removing-observations-during-create-table-step/m-p/479617#M71488</guid>
      <dc:creator>MillerEL</dc:creator>
      <dc:date>2018-07-19T20:34:30Z</dc:date>
    </item>
  </channel>
</rss>

