<?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 How to join several tables if certain tables do not exist? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-join-several-tables-if-certain-tables-do-not-exist/m-p/194507#M48805</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a question of joining data tables. Suppose my code will produce three tables A, B, and C and I want to join these three tables together. However, these three tables do not always exist and if&amp;nbsp; this happens, I just want to join the tables with data. For example, if table A does not exist then join B and C tables together. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that if you create a table with all columns but no data in it, you can still join it without error. However, my A, B, C tables are created from a macro and when the empty table will not have any columns. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore, I want to know what is the best practice to handle this situations?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tao&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Apr 2015 14:10:45 GMT</pubDate>
    <dc:creator>yangtaotai</dc:creator>
    <dc:date>2015-04-13T14:10:45Z</dc:date>
    <item>
      <title>How to join several tables if certain tables do not exist?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-join-several-tables-if-certain-tables-do-not-exist/m-p/194507#M48805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a question of joining data tables. Suppose my code will produce three tables A, B, and C and I want to join these three tables together. However, these three tables do not always exist and if&amp;nbsp; this happens, I just want to join the tables with data. For example, if table A does not exist then join B and C tables together. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that if you create a table with all columns but no data in it, you can still join it without error. However, my A, B, C tables are created from a macro and when the empty table will not have any columns. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore, I want to know what is the best practice to handle this situations?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tao&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Apr 2015 14:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-join-several-tables-if-certain-tables-do-not-exist/m-p/194507#M48805</guid>
      <dc:creator>yangtaotai</dc:creator>
      <dc:date>2015-04-13T14:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to join several tables if certain tables do not exist?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-join-several-tables-if-certain-tables-do-not-exist/m-p/194508#M48806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, you could conditionally execute parts of the code based on existence of the dataset name in sashelp.vtable.&amp;nbsp; However, my suggestion would be to create the three tables up front and have your macro append data to them.&amp;nbsp; That way you know they are always present.&amp;nbsp; Also important, if some data is not created, does that not mean your logic would fall over, i.e. if you are not getting what you expect, maybe re-think the original idea.&amp;nbsp; I.e. always know your data, and your process - this is more important than doing some coding.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Apr 2015 14:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-join-several-tables-if-certain-tables-do-not-exist/m-p/194508#M48806</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-04-13T14:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to join several tables if certain tables do not exist?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-join-several-tables-if-certain-tables-do-not-exist/m-p/194509#M48807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi RW9,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your reply!&amp;nbsp;&amp;nbsp; I wonder if I literally create a table with columns but no data in it and then my macro append A, B, and C to this temp table and this will guarantee the temp table will always have all the existing records. Not sure if this is what you are describing in your reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tao&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Apr 2015 15:30:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-join-several-tables-if-certain-tables-do-not-exist/m-p/194509#M48807</guid>
      <dc:creator>yangtaotai</dc:creator>
      <dc:date>2015-04-13T15:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to join several tables if certain tables do not exist?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-join-several-tables-if-certain-tables-do-not-exist/m-p/194510#M48808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, indeed that is my point.&amp;nbsp; Just simply create empty tables:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table A (id num,avar num);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table B (id num,avar num);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table C (id num,avar num);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then in your macro, rather than creating a dataset, just do:&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set a some_other data;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Apr 2015 17:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-join-several-tables-if-certain-tables-do-not-exist/m-p/194510#M48808</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-04-13T17:01:12Z</dc:date>
    </item>
  </channel>
</rss>

