<?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: SQL create table issue in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SQL-create-table-issue/m-p/78783#M22713</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem is likely to be with the natural join. Run this little test :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data a(drop=b) b(drop=a);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;do i = 1 to 5;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a = i*10;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = i**2;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;format a z10.2 b dollar6. i percent10.;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table c as&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;select i as i_in_c, a, b &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;from a natural join b;&lt;/STRONG&gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select * from c;&lt;/STRONG&gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table d as&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;select a.i as i_in_d, a, b &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;from a natural join b;&lt;/STRONG&gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select * from d;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;quit; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that the only difference between table c and table d is the fact that the origin of variable i is explicit in the select statement creating table d. Even when both variables in the join have the same format, the natural join drops the format. The solution is thus to mention one of the table names for every column involved in the join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 18 May 2013 15:55:30 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2013-05-18T15:55:30Z</dc:date>
    <item>
      <title>SQL create table issue</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-create-table-issue/m-p/78782#M22712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code seems to work as expected but it loses the labels and formats that should be copied from the "updated." table. Can you suggest a method to retain these dataset attributes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;dsName = name of the dataset being processed&lt;/P&gt;&lt;P&gt;&amp;amp;pt = subject identifier&lt;/P&gt;&lt;P&gt;%dsSQLcolumns = list of columns to be selected for the "except" statement.&lt;/P&gt;&lt;P&gt;%dsSEQk = additional columns to be added onto the final "except_" table but are not part of the "except" statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;SPAN style="color: #575757; text-decoration: underline;"&gt;Please note that there is no primary key in the datasets that I can pick.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt; &lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table except_&amp;amp;dsname&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %&lt;STRONG&gt;&lt;EM&gt;dsSQLcolumns&lt;/EM&gt;&lt;/STRONG&gt;(ds=&amp;amp;dsname) &lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New'; background-color: #ffffff;"&gt;%&lt;/SPAN&gt;&lt;STRONG style="color: #000000; font-family: 'Courier New';"&gt;&lt;EM&gt;dsSEQk&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New'; background-color: #ffffff;"&gt;(ds=&amp;amp;dsname)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: teal; background-color: white;"&gt;updated.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;amp;dsname&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; natural join&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (select&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %&lt;STRONG&gt;&lt;EM&gt;dsSQLcolumns&lt;/EM&gt;&lt;/STRONG&gt;(ds=&amp;amp;dsname)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: teal; background-color: white;"&gt;updated.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;amp;dsname&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where usubjid=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: purple; background-color: white;"&gt;"&amp;amp;pt"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %&lt;STRONG&gt;&lt;EM&gt;dsSQLcolumns&lt;/EM&gt;&lt;/STRONG&gt;(ds=&amp;amp;dsname)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: teal; background-color: white;"&gt;olddata.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;amp;dsname&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where usubjid=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: purple; background-color: white;"&gt;"&amp;amp;pt"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 11pt; font-family: Calibri, sans-serif; color: #000000;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 May 2013 11:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-create-table-issue/m-p/78782#M22712</guid>
      <dc:creator>Mikeyjh</dc:creator>
      <dc:date>2013-05-18T11:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: SQL create table issue</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-create-table-issue/m-p/78783#M22713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem is likely to be with the natural join. Run this little test :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data a(drop=b) b(drop=a);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;do i = 1 to 5;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a = i*10;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = i**2;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;format a z10.2 b dollar6. i percent10.;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table c as&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;select i as i_in_c, a, b &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;from a natural join b;&lt;/STRONG&gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select * from c;&lt;/STRONG&gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table d as&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;select a.i as i_in_d, a, b &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;from a natural join b;&lt;/STRONG&gt;&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select * from d;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;quit; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that the only difference between table c and table d is the fact that the origin of variable i is explicit in the select statement creating table d. Even when both variables in the join have the same format, the natural join drops the format. The solution is thus to mention one of the table names for every column involved in the join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 May 2013 15:55:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-create-table-issue/m-p/78783#M22713</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-05-18T15:55:30Z</dc:date>
    </item>
  </channel>
</rss>

