<?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 CREATE TABLE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/CREATE-TABLE/m-p/663747#M198208</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is probably basic question for many but I am struggling to understand why this is happening. I see that the output using CREATE TABLE and not using it are different. My understanding is create table is just to create a dataset, hence I am curious why I see these differences.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample datasets:&amp;nbsp;&lt;/P&gt;&lt;P&gt;dataset three:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;X A&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1 a1&lt;/P&gt;&lt;P&gt;1 a2&lt;/P&gt;&lt;P&gt;2 b1&lt;/P&gt;&lt;P&gt;2 b2&lt;/P&gt;&lt;P&gt;4 d&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dataset four:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;X A&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2 x1&lt;/P&gt;&lt;P&gt;2 x2&lt;/P&gt;&lt;P&gt;3 y&lt;/P&gt;&lt;P&gt;5 v&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output is as expected when I run&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select *&lt;BR /&gt;from three full join four&lt;BR /&gt;on three.x = four.x;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it is different when I run the same with&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp;create table five as&amp;nbsp;&lt;BR /&gt;select *&lt;BR /&gt;from three full join four&lt;BR /&gt;on three.x = four.x;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With create table I do not see a repetitive X variable which should be the case with proc sql joins (ie. both x columns from both datasets should be seen). The other thing I noticed is the values 3 and 5 from dataset four are missing. Please help understanding this!!&lt;/P&gt;</description>
    <pubDate>Sat, 20 Jun 2020 19:36:09 GMT</pubDate>
    <dc:creator>Tommer</dc:creator>
    <dc:date>2020-06-20T19:36:09Z</dc:date>
    <item>
      <title>CREATE TABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CREATE-TABLE/m-p/663747#M198208</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is probably basic question for many but I am struggling to understand why this is happening. I see that the output using CREATE TABLE and not using it are different. My understanding is create table is just to create a dataset, hence I am curious why I see these differences.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample datasets:&amp;nbsp;&lt;/P&gt;&lt;P&gt;dataset three:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;X A&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1 a1&lt;/P&gt;&lt;P&gt;1 a2&lt;/P&gt;&lt;P&gt;2 b1&lt;/P&gt;&lt;P&gt;2 b2&lt;/P&gt;&lt;P&gt;4 d&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dataset four:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;X A&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2 x1&lt;/P&gt;&lt;P&gt;2 x2&lt;/P&gt;&lt;P&gt;3 y&lt;/P&gt;&lt;P&gt;5 v&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output is as expected when I run&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select *&lt;BR /&gt;from three full join four&lt;BR /&gt;on three.x = four.x;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it is different when I run the same with&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp;create table five as&amp;nbsp;&lt;BR /&gt;select *&lt;BR /&gt;from three full join four&lt;BR /&gt;on three.x = four.x;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With create table I do not see a repetitive X variable which should be the case with proc sql joins (ie. both x columns from both datasets should be seen). The other thing I noticed is the values 3 and 5 from dataset four are missing. Please help understanding this!!&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jun 2020 19:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CREATE-TABLE/m-p/663747#M198208</guid>
      <dc:creator>Tommer</dc:creator>
      <dc:date>2020-06-20T19:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CREATE-TABLE/m-p/663752#M198209</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/284458"&gt;@Tommer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you read the log associated with the second PROC SQL, you will see that SAS put a Warning. Indeed, it is not a problem&amp;nbsp;&lt;SPAN style="font-family: inherit; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;"&gt;to create a report with two columns with the same name, but it is completely different when you want to create a dataset because&amp;nbsp;SAS cannot manage to have several columns with identical names.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;"&gt;&lt;BR /&gt;The COLAESCE function is designed to handle such cases:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table five as 
select coalesce (three.x, four.x) as x, coalesce (three.a, four.a) as a&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;"&gt;-&amp;gt; it will retrieve all values coming from each x variable in the same column.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;"&gt;Best,&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jun 2020 20:00:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CREATE-TABLE/m-p/663752#M198209</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-06-20T20:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CREATE-TABLE/m-p/663756#M198210</link>
      <description>&lt;P&gt;To avoid duplicate column names, give some of them new names :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table five as 
select three.*, four.x as xx, four.a as aa
from three full join four
on three.x = four.x;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Jun 2020 20:22:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CREATE-TABLE/m-p/663756#M198210</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-06-20T20:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CREATE-TABLE/m-p/663862#M198260</link>
      <description>Understood, so that's where the difference comes in when I am creating a table vs not creating one. When I don't use CREATE TABLE the output was as I thought it would be with additional columns etc, but once I used CREATE TABLE the output seemed very different as you explained creating dataset with multiple similar names.</description>
      <pubDate>Sun, 21 Jun 2020 18:21:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CREATE-TABLE/m-p/663862#M198260</guid>
      <dc:creator>Tommer</dc:creator>
      <dc:date>2020-06-21T18:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TABLE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CREATE-TABLE/m-p/663871#M198267</link>
      <description>&lt;P&gt;When you are not explicitly creating a table, SAS/SQL chooses to create the new column names silently since all you are going to see anyway are column labels (which do not have to be unique). But when you explicitly create a table, SAS chooses not to assign column names (and generate an error) because, I suppose, you might not get what you expected. You can capture the underlying table created when you don't explicitly create a table with ODS OUTPUT, like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data three;
input X A $;
datalines;
1 a1
1 a2
2 b1
2 b2
4 d
;
 
data four;
input X A $;
datalines;
2 x1
2 x2
3 y
5 v
;
 
ods output Sql_Results=six;
proc sql;
select *
from three full join four
on three.x = four.x;
describe table six;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Look at the log.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jun 2020 20:12:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CREATE-TABLE/m-p/663871#M198267</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-06-21T20:12:32Z</dc:date>
    </item>
  </channel>
</rss>

