<?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: GETTING ERROR in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258560#M49829</link>
    <description>&lt;P&gt;I think the OP is actually doing sort of Proc compare step.&lt;/P&gt;
&lt;P&gt;Consider:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testing;
   input x y z;
datalines;
1 2 3
4 5 6
4 5 6
;
run;

proc sql noprint;
   select count (*)  into :A 
   from testing;

   select count(*) into :B  from
      (
      select *  from testing
      UNION
      select *  from testing) 
   ;
quit;

%put A= &amp;amp;a   B=&amp;amp;b;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The counts do differ.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you don't really know where the difference only that there is one or more duplicate records in the base set.&lt;/P&gt;
&lt;P&gt;I'm not really sure if there is an advantage of the Union as opposed to Select Distinct though.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Mar 2016 15:27:03 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-03-23T15:27:03Z</dc:date>
    <item>
      <title>GETTING ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258535#M49818</link>
      <description>&lt;P&gt;%MACRO testing;&lt;BR /&gt;proc sql;&lt;BR /&gt;select count (*)&amp;nbsp; into :A from test1.testing;&lt;BR /&gt;&lt;BR /&gt;select count(*) into :B&amp;nbsp; from&lt;BR /&gt;(&lt;BR /&gt;select *&amp;nbsp; from test1.testing&lt;BR /&gt;UNION&lt;BR /&gt;select *&amp;nbsp; from test1.testing) T1;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%if &amp;amp;A=&amp;amp;B %then&lt;BR /&gt;%do;&lt;BR /&gt;%put testing is unique table;&lt;BR /&gt;&lt;BR /&gt;%end;&lt;BR /&gt;%else&lt;BR /&gt;%put testing is non unique table;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sql;&lt;BR /&gt;select tablename&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :inputtables separated by ',' from test1.tc_inputs2;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;%put &amp;amp;inputtables;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%testing;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 14:16:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258535#M49818</guid>
      <dc:creator>PN00429118</dc:creator>
      <dc:date>2016-03-23T14:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258537#M49819</link>
      <description>&lt;P&gt;So what is the question? &amp;nbsp;I do not see, test data, error log, required output, what the code is supposed to do etc.? &amp;nbsp;I can tell you that you are missing the word proc from the last sql step. &amp;nbsp;I can also say that I see no need for a macro here at all, please explain what you are doing and why.&lt;/P&gt;
&lt;P&gt;For example Base SAS:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  merge sashelp.vtable (where=(libname="SASHELP" and memname="CLASS"))
        sashelp.vtable (where=(libname="SASHELP" and memname="CLASS") rename=(nobs=b_nobs));
  if nobs=b_nobs then put "Unique table";
  else put "Non unique table";
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Mar 2016 14:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258537#M49819</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-23T14:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258538#M49820</link>
      <description>&lt;P&gt;It helps if you show the log.&lt;/P&gt;
&lt;P&gt;My first idea is that you are missing a PROC before the second SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are you trying to accomplish, anyway?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 14:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258538#M49820</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-03-23T14:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258544#M49821</link>
      <description>&lt;P&gt;I could be wrong here, but ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even if you eliminate the error, willl the program ever work correctly?&amp;nbsp; My understanding of UNION is that it just appends records.&amp;nbsp; The result would always be that &amp;amp;A * 2 = &amp;amp;B.&amp;nbsp; You might want to describe what you are identifying as a "unique table" because you probably need to change the test that you are making.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 14:36:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258544#M49821</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-23T14:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258557#M49827</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I could be wrong here, but ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even if you eliminate the error, willl the program ever work correctly?&amp;nbsp; My understanding of UNION is that it just appends records.&amp;nbsp; The result would always be that &amp;amp;A * 2 = &amp;amp;B.&amp;nbsp; You might want to describe what you are identifying as a "unique table" because you probably need to change the test that you are making.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Per SQL norm, a UNION always implies DISTINCT, so the condition would always be true, making the whole test futile.&lt;/P&gt;
&lt;P&gt;(Tested it with SASHELP.CLASS)&lt;/P&gt;
&lt;P&gt;So we dearly need to know what the OP's intentions are.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 15:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258557#M49827</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-03-23T15:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258560#M49829</link>
      <description>&lt;P&gt;I think the OP is actually doing sort of Proc compare step.&lt;/P&gt;
&lt;P&gt;Consider:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testing;
   input x y z;
datalines;
1 2 3
4 5 6
4 5 6
;
run;

proc sql noprint;
   select count (*)  into :A 
   from testing;

   select count(*) into :B  from
      (
      select *  from testing
      UNION
      select *  from testing) 
   ;
quit;

%put A= &amp;amp;a   B=&amp;amp;b;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The counts do differ.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you don't really know where the difference only that there is one or more duplicate records in the base set.&lt;/P&gt;
&lt;P&gt;I'm not really sure if there is an advantage of the Union as opposed to Select Distinct though.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 15:27:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258560#M49829</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-03-23T15:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258562#M49830</link>
      <description>&lt;P&gt;If that is indeed the case then why not simply (have just bashed this out quickly, not tested):&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table MISS1 as
  select  *
  from    FIRST_TABLE
  except  (select * from SECOND_TABLE);
  create table MISS2 as
  select  *
  from    SECOND_TABLE
  except  (select * from FIRST_TABLE);
quit;&lt;/PRE&gt;
&lt;P&gt;You get two datasets one for each missing from the other, easy to see what is missing then.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 15:21:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258562#M49830</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-23T15:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258563#M49831</link>
      <description>&lt;P&gt;Yeah, that's it. Just a very complicated way of checking for duplicates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select count(*) into :A from testing;
select count (*) into :B from (select distinct * from testing);
quit;
data _null_;
if &amp;amp;A ne &amp;amp;B then put "not unique";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Mar 2016 15:29:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/GETTING-ERROR/m-p/258563#M49831</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-03-23T15:29:25Z</dc:date>
    </item>
  </channel>
</rss>

