<?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: Where+Rename+IN options in merge in proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Where-Rename-IN-options-in-merge-in-proc-sql/m-p/490755#M128496</link>
    <description>&lt;P&gt;Please differentiate what is SAS syntax and what is SQL syntax.&amp;nbsp; Whilst you can use some dataset options in SQL, it really isn't recommended.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql; 
  create table output as
  select a.*,
         b.obligo as totalobligo   
  from   (select * from allmodels where _type_=3) a,
         (select * from allmodels where _type_=0) b;
quit;&lt;/PRE&gt;
&lt;P&gt;Do note a few things also, select * from multiple tables will cause you issues.&amp;nbsp; The principal is that you should know your data, know what it contains, and what you want in the output.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Aug 2018 08:25:26 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-08-29T08:25:26Z</dc:date>
    <item>
      <title>Where+Rename+IN options in merge in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Rename-IN-options-in-merge-in-proc-sql/m-p/490735#M128481</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I am running merge in proc sql.&lt;/P&gt;&lt;P&gt;I have Where+Rename+IN &amp;nbsp;statements .&lt;/P&gt;&lt;P&gt;I get an error so I think that the order of &amp;nbsp;them is not correct&lt;/P&gt;&lt;P&gt;What is the correct order of &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Where+Rename+IN options in merge?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What is the logic of the correct order? IS there order of actions?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
	create table output as
	select 	a.*,b.*   
	from AllModels(where=(_TYPE_=3)in=a ),
         AllModels(where=(_TYPE_=0)  rename=(Obligo=TotalObligo )in=b) 
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 06:34:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Rename-IN-options-in-merge-in-proc-sql/m-p/490735#M128481</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-29T06:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: Where+Rename+IN options in merge in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Rename-IN-options-in-merge-in-proc-sql/m-p/490742#M128485</link>
      <description>&lt;P&gt;in = dataset options are only valid in data steps.&lt;/P&gt;
&lt;P&gt;What you are looking for in SQL are table &lt;EM&gt;aliases&lt;/EM&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table output as
select
 a.*,b.*   
from
  AllModels (
    where=(_TYPE_=3)
  ) as a,
  AllModels (
    where=(_TYPE_=0)
    rename=(Obligo=TotalObligo)
  ) as b 
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that this SQL willl create a cartesian product (the target dataset will have (nobs of AllModels) ** 2 observations).&lt;/P&gt;
&lt;P&gt;It will also create a NOTE or WARNING for columns already present.&lt;/P&gt;
&lt;P&gt;Could it be you are looking for a vertical stacking of datasets? That would best be achieved with a simple data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 07:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Rename-IN-options-in-merge-in-proc-sql/m-p/490742#M128485</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-29T07:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Where+Rename+IN options in merge in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Rename-IN-options-in-merge-in-proc-sql/m-p/490755#M128496</link>
      <description>&lt;P&gt;Please differentiate what is SAS syntax and what is SQL syntax.&amp;nbsp; Whilst you can use some dataset options in SQL, it really isn't recommended.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql; 
  create table output as
  select a.*,
         b.obligo as totalobligo   
  from   (select * from allmodels where _type_=3) a,
         (select * from allmodels where _type_=0) b;
quit;&lt;/PRE&gt;
&lt;P&gt;Do note a few things also, select * from multiple tables will cause you issues.&amp;nbsp; The principal is that you should know your data, know what it contains, and what you want in the output.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 08:25:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Rename-IN-options-in-merge-in-proc-sql/m-p/490755#M128496</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-29T08:25:26Z</dc:date>
    </item>
  </channel>
</rss>

