<?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: How to merge one table with another table containing no observations? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/367156#M87376</link>
    <description>&lt;P&gt;I'm not sure what you mean here. If the base data doesn't exist for PROC APPEND, SAS will create it and not produce an error.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jun 2017 22:18:15 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-06-14T22:18:15Z</dc:date>
    <item>
      <title>How to merge one table with another table containing no observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/365945#M86980</link>
      <description>&lt;P&gt;Hello:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;On the Combine attachment, I have a NEW table&amp;nbsp;contains three variables. &amp;nbsp;Another OLD table contains only five variables without any observations. &amp;nbsp;The variable format of OLD table is the same as NEW. &amp;nbsp; The Age is three digit and the Sex is the character. &amp;nbsp; However, &amp;nbsp;the tables list in the attachment&amp;nbsp;are only just examples. &amp;nbsp;My&lt;SPAN&gt; actual table NEW has 400 variables and OLD table has 600 variables. &amp;nbsp;&lt;/SPAN&gt;How to merge them to a table containing all the variables and observations, like 'Merge' tab of the Excel sheet? &amp;nbsp;Thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 00:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/365945#M86980</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-11T00:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge one table with another table containing no observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/365949#M86983</link>
      <description>&lt;P&gt;say you table abc then alter table add new columns(b,c) you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data abc;&lt;BR /&gt;a=10;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;alter table abc add b char(10), c num format=10.;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 00:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/365949#M86983</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-11T00:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge one table with another table containing no observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/365950#M86984</link>
      <description>&lt;P&gt;One table is essentially your table structure.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm making big assumptions because you haven't provided any details.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Tables are alrady in SAS&lt;/P&gt;
&lt;P&gt;2. 'Empty' table is your desired table structure&lt;/P&gt;
&lt;P&gt;3. Types match between tables already, ie Sex is the same type (character) in both datasets.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are several solutions to this problem, including: a data step with datasets listed in the SET statement, PROC APPEND, or a SQL Insert.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set empty /*your empty table structure*/
      insert /*your table with data*/;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc append base = empty data=insert;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, RTM.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is an entire section&amp;nbsp;dedicated to 'combining' datasets.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Concatenating datasets is one of the first things covered.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#p0sz8gq6nvzcojn13pcqe3twvg1d.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#p0sz8gq6nvzcojn13pcqe3twvg1d.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the section on Common Problems is one you should review since you're likely to encounter at least one if you're trying to do this.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#p15jvywi5avt3cn1bee8r6c33ux1.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#p15jvywi5avt3cn1bee8r6c33ux1.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 00:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/365950#M86984</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-11T00:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge one table with another table containing no observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/365951#M86985</link>
      <description>&lt;P&gt;Your idea is great. &amp;nbsp;However, my actual table NEW has 400 variables and OLD table has 600 variables.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 00:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/365951#M86985</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-11T00:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge one table with another table containing no observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/365952#M86986</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Your idea is great. &amp;nbsp;However, my actual table NEW has 400 variables and OLD table has 600 variables.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should know by now to include sample data as text not XLSX and to include this type of information&amp;nbsp;in your question from the start.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 00:48:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/365952#M86986</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-11T00:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge one table with another table containing no observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/365953#M86987</link>
      <description>&lt;P&gt;something like below should work, answer is very similar to what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;has written&lt;/P&gt;
&lt;PRE&gt;/* your intial table with your records*/&lt;BR /&gt;data intialtable;
a=10;
run;
/* this is your empty table as intial table 
where you have records*/
proc sql;
create table uyuy
like abc;

/* this is empty table you have*/
proc sql;
create table xyxx 
(gg num);

/* here you will get all columns by  cross join*/
proc sql;
create table final_tabl as
select a.*, b.* from uyuy a
cross join xyxx b;

/* do a proc append to your final_tabl &lt;BR /&gt;which has all columns you need and insert data from table where you have data*/
proc append base =final_tabl
data =intialtab ;
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 01:14:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/365953#M86987</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-11T01:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge one table with another table containing no observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/365955#M86988</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Not sure why you believe what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;proposes will create more work for you with a lot of variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below some code which illustrates how you can do this independent of the number of variables in your source data sets.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data old;
  stop;
  set sashelp.class sashelp.classfit;
run;

data new;
  length sex $3;
  set sashelp.class;
run;

/****
  option 1:
  works well as long as same named variables are of same type and length 
****/
data want;
  set old(obs=0) new;
run;


/**** 
  option 2:
  outer union corr will create output table with max length
  of same named variables from input tables
  variables must still be of same data type (num or char)
****/
proc sql;
  create table want2 as
    select *
    from old(obs=0)
    outer union corr
    select *
    from new
    ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Jun 2017 02:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/365955#M86988</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-06-11T02:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge one table with another table containing no observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/366309#M87130</link>
      <description>&lt;P&gt;Thanks for all your kind help.&amp;nbsp; I am still working on input the stardard sheet into the SAS.&amp;nbsp; I will try this program later.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 19:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/366309#M87130</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-12T19:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge one table with another table containing no observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/366953#M87330</link>
      <description>&lt;P&gt;Hi, Reeza:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;used the proc append as you suggested.&amp;nbsp; However, I&amp;nbsp;found&amp;nbsp;the&amp;nbsp;empty&amp;nbsp;dataset has been changed to&amp;nbsp;new merged&amp;nbsp;dataset.&amp;nbsp; Is there a way to create new data without using&amp;nbsp;OLD empty one?&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;proc&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;append&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; base &lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;=&lt;/FONT&gt;&lt;/SPAN&gt; empty &lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;data&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;=&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;&lt;FONT color="#0000ff"&gt;insert&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 13:44:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/366953#M87330</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-14T13:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge one table with another table containing no observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/367156#M87376</link>
      <description>&lt;P&gt;I'm not sure what you mean here. If the base data doesn't exist for PROC APPEND, SAS will create it and not produce an error.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 22:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/367156#M87376</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-14T22:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge one table with another table containing no observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/367199#M87387</link>
      <description>&lt;P&gt;Sorry for not expressing clearly. &amp;nbsp;I would like to keep the empty table (the one with names only) intact. &amp;nbsp;However, I found that the final merged table was found in the table 'empty'. &amp;nbsp; Could I create a new table after the merging? &amp;nbsp; I would like to keep the empty table for future use repeatedly. &amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 01:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/367199#M87387</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-15T01:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge one table with another table containing no observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/367207#M87391</link>
      <description>&lt;P&gt;I commented the code. If you understand the steps you should be able to remove the step that's unnecessary. I think it's pretty clear from the comments.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: there are two solutions in my post. One will do what you want. Append is just that, it appends to a data set. Im guessing you didn't read the link I posted. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 02:26:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-one-table-with-another-table-containing-no/m-p/367207#M87391</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-15T02:26:46Z</dc:date>
    </item>
  </channel>
</rss>

