<?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 appending / inserting into a data table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76252#M16480</link>
    <description>What is the best way using a data set to append data to an existing data set?&lt;BR /&gt;
&lt;BR /&gt;
If I have &lt;BR /&gt;
table A&lt;BR /&gt;
NAME AGE&lt;BR /&gt;
Bob 33&lt;BR /&gt;
Fred 40&lt;BR /&gt;
&lt;BR /&gt;
now I want to add all the rows from a different data set into table A.&lt;BR /&gt;
&lt;BR /&gt;
table B&lt;BR /&gt;
NAME AGE&lt;BR /&gt;
William 74&lt;BR /&gt;
Dan 29&lt;BR /&gt;
&lt;BR /&gt;
After append/insert&lt;BR /&gt;
&lt;BR /&gt;
table A&lt;BR /&gt;
NAME AGE&lt;BR /&gt;
Bob 33&lt;BR /&gt;
Fred 40&lt;BR /&gt;
William 74&lt;BR /&gt;
Dan 29</description>
    <pubDate>Wed, 04 Mar 2009 17:52:55 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-03-04T17:52:55Z</dc:date>
    <item>
      <title>appending / inserting into a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76252#M16480</link>
      <description>What is the best way using a data set to append data to an existing data set?&lt;BR /&gt;
&lt;BR /&gt;
If I have &lt;BR /&gt;
table A&lt;BR /&gt;
NAME AGE&lt;BR /&gt;
Bob 33&lt;BR /&gt;
Fred 40&lt;BR /&gt;
&lt;BR /&gt;
now I want to add all the rows from a different data set into table A.&lt;BR /&gt;
&lt;BR /&gt;
table B&lt;BR /&gt;
NAME AGE&lt;BR /&gt;
William 74&lt;BR /&gt;
Dan 29&lt;BR /&gt;
&lt;BR /&gt;
After append/insert&lt;BR /&gt;
&lt;BR /&gt;
table A&lt;BR /&gt;
NAME AGE&lt;BR /&gt;
Bob 33&lt;BR /&gt;
Fred 40&lt;BR /&gt;
William 74&lt;BR /&gt;
Dan 29</description>
      <pubDate>Wed, 04 Mar 2009 17:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76252#M16480</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-04T17:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: appending / inserting into a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76253#M16481</link>
      <description>One approach is to use a DATA step and a SET statement with the two files specified on the SET.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 04 Mar 2009 18:32:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76253#M16481</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-03-04T18:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: appending / inserting into a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76254#M16482</link>
      <description>Scott,&lt;BR /&gt;
That works but my column names have to match up and they don't.  Do I have to do a rename on the columns that don't?  Is there a different way to do it or is this the cleanest and fastest way?&lt;BR /&gt;
&lt;BR /&gt;
thank you again for your help&lt;BR /&gt;
&lt;BR /&gt;
Jerry</description>
      <pubDate>Wed, 04 Mar 2009 19:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76254#M16482</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-04T19:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: appending / inserting into a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76255#M16483</link>
      <description>You'll want to validate your input tables using PROC CONTENTS, and then use RENAME= on the SET statement when combining your files.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 04 Mar 2009 21:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76255#M16483</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-03-04T21:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: appending / inserting into a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76256#M16484</link>
      <description>sql union operator &lt;I&gt;without&lt;/I&gt; CORRESPONDING may be able to achieve what you want, but if the internal (varnum) order is not going to line up the variables as you want, then you'll need to list the columns of one table in the order you need to line up with the other table. &lt;BR /&gt;
And, of course, you probably need the ALL option of UNION. See&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473694.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473694.htm&lt;/A&gt; .&lt;BR /&gt;
 &lt;BR /&gt;
good luck&lt;BR /&gt;
 &lt;BR /&gt;
PeterC</description>
      <pubDate>Wed, 04 Mar 2009 22:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76256#M16484</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-03-04T22:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: appending / inserting into a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76257#M16485</link>
      <description>Peter thanks for the reply but I can't use proc sql it has to be a data step. &lt;BR /&gt;
Scott I did the following to get around it&lt;BR /&gt;
In one data table I had a column defined as character and the table i'm joining too has it as numeric so I had to do this to get around it and it works.&lt;BR /&gt;
&lt;BR /&gt;
data temp ;&lt;BR /&gt;
	set temp2 ;	&lt;BR /&gt;
	idnumeric = input(id,best.) ;&lt;BR /&gt;
	rename id=idchar ;&lt;BR /&gt;
	rename idnumeric = id ;&lt;BR /&gt;
run ;&lt;BR /&gt;
&lt;BR /&gt;
Thank you &lt;BR /&gt;
Jerry</description>
      <pubDate>Thu, 05 Mar 2009 13:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76257#M16485</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-05T13:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: appending / inserting into a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76258#M16486</link>
      <description>Jerry&lt;BR /&gt;
 &lt;BR /&gt;
why can't you use PROC SQL for this problem ?&lt;BR /&gt;
  &lt;BR /&gt;
PeterC</description>
      <pubDate>Thu, 05 Mar 2009 13:57:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76258#M16486</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-03-05T13:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: appending / inserting into a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76259#M16487</link>
      <description>Boss wants data steps only.  Since i'm new he says it will help me learn more about sas.</description>
      <pubDate>Thu, 05 Mar 2009 14:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76259#M16487</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-05T14:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: appending / inserting into a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76260#M16488</link>
      <description>Don't use datasteps for appending data sets - It will read every record from both datasets making it a very slow proces. It requires that your datatypes are the same - or look at the FORCE option.&lt;BR /&gt;
&lt;BR /&gt;
[pre]data table_B;&lt;BR /&gt;
  input NxME $ xGE;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
William 74&lt;BR /&gt;
Dan 29&lt;BR /&gt;
;run;&lt;BR /&gt;
 &lt;BR /&gt;
data table_A;&lt;BR /&gt;
  input NAME $ AGE;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
Bob 33&lt;BR /&gt;
Fred 40&lt;BR /&gt;
;run;&lt;BR /&gt;
 &lt;BR /&gt;
proc append &lt;BR /&gt;
  data=table_b(rename=(nxme=name xge=age)) &lt;BR /&gt;
  base=table_a; &lt;BR /&gt;
run;[/pre]</description>
      <pubDate>Fri, 06 Mar 2009 13:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76260#M16488</guid>
      <dc:creator>GertNissen</dc:creator>
      <dc:date>2009-03-06T13:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: appending / inserting into a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76261#M16489</link>
      <description>Yep, if your boss wants you to learn more about programming efficiently then he'll be looking for proc append.</description>
      <pubDate>Fri, 06 Mar 2009 14:42:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76261#M16489</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-06T14:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: appending / inserting into a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76262#M16490</link>
      <description>pznew,&lt;BR /&gt;
Thanks for the tip.  I finally got it working in a data step, but I want to try the append.&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Fri, 06 Mar 2009 14:48:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76262#M16490</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-06T14:48:41Z</dc:date>
    </item>
    <item>
      <title>appending / inserting into a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76263#M16491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi Zineg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanx for the performance advice regarding proc append/data step. I always use proc append but never had a thought on whether it was faster that the data step solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best wishes&lt;/P&gt;&lt;P&gt;Eva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 10:12:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76263#M16491</guid>
      <dc:creator>Eva</dc:creator>
      <dc:date>2012-02-01T10:12:08Z</dc:date>
    </item>
    <item>
      <title>appending / inserting into a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76264#M16492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PROC APPEND BASE = TABLEA DATA=TABLEB;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 20:53:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76264#M16492</guid>
      <dc:creator>Hima</dc:creator>
      <dc:date>2012-02-01T20:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: appending / inserting into a data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76265#M16493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, PROC APPEND is not a data step...&lt;/P&gt;&lt;P&gt;To be able to rename columns with proc append, you need to use the rename data set option, otherwise you'll loose data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I like the syntax of SQL better for this case, the select clause of the insert statement lets you list which columns to insert, and is does not care for names, just position and data type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And is almost as efficient as append.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/Linus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2012 10:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-inserting-into-a-data-table/m-p/76265#M16493</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2012-02-02T10:09:46Z</dc:date>
    </item>
  </channel>
</rss>

