<?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: appending a SAS dataset to existing sql server table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136637#M27655</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to manually match up the columns in the two clauses.&amp;nbsp; You shouldn't include the identity column but only those that you have in your sas table.&amp;nbsp; I may have the table names reversed...but it sounds like you're inserting into the sql table and selecting from the sas dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;insert into sqllibname.sqltable (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; columns that match the sas dataset&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; column names in the same order as above&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; saslibrary.sastable;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Jan 2014 21:54:33 GMT</pubDate>
    <dc:creator>DBailey</dc:creator>
    <dc:date>2014-01-09T21:54:33Z</dc:date>
    <item>
      <title>appending a SAS dataset to existing sql server table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136632#M27650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear SAS community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to add a SAS dataset to an existing SQL Server table.&amp;nbsp; I would like to add the SAS dateset "adding" to the sql table "have."&amp;nbsp; I have been using the below code.&lt;/P&gt;&lt;P&gt;proc append base=SQLSERVER.have data=WORK.adding;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, when I run the code, I receive this error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Appending WORK.adding to SQLSERVER.have.&lt;/P&gt;&lt;P&gt;WARNING: Variable X1 was not found on DATA file.&lt;/P&gt;&lt;P&gt;WARNING: Variable X2 was not found on DATA file.&lt;/P&gt;&lt;P&gt;WARNING: Variable X3 was not found on DATA file.&lt;/P&gt;&lt;P&gt;NOTE: There were 1 observations read from the data set WORK.adding.&lt;/P&gt;&lt;P&gt;NOTE: 0 observations added.&lt;/P&gt;&lt;P&gt;NOTE: The data set SQLSERVER.have&amp;nbsp; has . observations and 44 variables.&lt;/P&gt;&lt;P&gt;ERROR: CLI execute error: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert explicit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value for identity column in table 'have' when IDENTITY_INSERT is set to OFF.&lt;/P&gt;&lt;P&gt;NOTE: Statements not processed because of errors oted above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe the errors are a result of two reasons.&lt;/P&gt;&lt;P&gt;1) I have variables (i.e. variables X1, X2, X3) in the SQL table that are not in the SAS dataset&lt;/P&gt;&lt;P&gt;2) I have one variable (i.e. variable X4) in the SQL table that is in a different format as that same variable in the SAS dataset&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to force the append without adding variables to the SAS dataset? And without changing the format of the variable shared by both sources?&lt;BR /&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 17:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136632#M27650</guid>
      <dc:creator>sophia_SAS</dc:creator>
      <dc:date>2014-01-09T17:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: appending a SAS dataset to existing sql server table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136633#M27651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since you have an identity column in sql you need to specify the columns that you're inserting into:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;insert into have (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; col1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; col2,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; col1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; col2,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;from want;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 18:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136633#M27651</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2014-01-09T18:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: appending a SAS dataset to existing sql server table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136634#M27652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just use "force" on the PROC APPEND....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc append base=base.data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data=work.data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; force;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 18:58:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136634#M27652</guid>
      <dc:creator>OS2Rules</dc:creator>
      <dc:date>2014-01-09T18:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: appending a SAS dataset to existing sql server table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136635#M27653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The force command did not work and I received the same error message as indicated in the original post.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 21:22:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136635#M27653</guid>
      <dc:creator>sophia_SAS</dc:creator>
      <dc:date>2014-01-09T21:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: appending a SAS dataset to existing sql server table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136636#M27654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I try this method, I receive any error that says "ERROR: Attempt to insert fewer columns than specified after the insert table name.&amp;nbsp; What do you advise?&amp;nbsp; My base table 'Have' does have more variables than my SAS dataset "want".&amp;nbsp; I would like to keep it that way, so how to amend the SQL insert code to reflect the following scenario . . .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;insert into have (&lt;/P&gt;&lt;P&gt;col 1,&lt;/P&gt;&lt;P&gt;col 2,&lt;/P&gt;&lt;P&gt;col 3&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;col1,&lt;/P&gt;&lt;P&gt;col3&lt;/P&gt;&lt;P&gt;from want;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 21:31:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136636#M27654</guid>
      <dc:creator>sophia_SAS</dc:creator>
      <dc:date>2014-01-09T21:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: appending a SAS dataset to existing sql server table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136637#M27655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to manually match up the columns in the two clauses.&amp;nbsp; You shouldn't include the identity column but only those that you have in your sas table.&amp;nbsp; I may have the table names reversed...but it sounds like you're inserting into the sql table and selecting from the sas dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;insert into sqllibname.sqltable (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; columns that match the sas dataset&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; column names in the same order as above&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; saslibrary.sastable;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 21:54:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136637#M27655</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2014-01-09T21:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: appending a SAS dataset to existing sql server table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136638#M27656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks that clears it up!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 23:49:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136638#M27656</guid>
      <dc:creator>sophia_SAS</dc:creator>
      <dc:date>2014-01-09T23:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: appending a SAS dataset to existing sql server table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136639#M27657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe the FORCE option only manages the cases where you're having variables in source not existing in target. What you need is to have all target columns in source. This could be done via an additional mapping step, eg:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data work.data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set base.data(obs=0) work.data;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc append base=base.data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data=work.data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; force nowarn;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jan 2014 08:58:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/appending-a-SAS-dataset-to-existing-sql-server-table/m-p/136639#M27657</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-01-10T08:58:39Z</dc:date>
    </item>
  </channel>
</rss>

