SAS Append error

Accepted Solution Solved
Reply
Regular Contributor
Posts: 190
Accepted Solution

SAS Append error

I am trying to append a dataset with different variables to base dataset with FORCE option. However everytime the loop iterates, it adds observations but is not adding the variable from the new dataset. Any suggestions?


Accepted Solutions
Solution
‎08-19-2013 07:01 AM
Respected Advisor
Posts: 4,173

Re: SAS Append error

Posted in reply to munitech4u

Re-writing the table is required to add or remove variables from a SAS table. This is something you can achieve with a data step and a set statement or with a SQL statement.

Proc Append "only" concatenates a new data set to an existing base table. The base table does not get re-written - and that's why Proc Append is so efficient. But: Because the base table does not get re-written you also can't add or remove variables from it.

The FORCE option allows you to append a new data set even if it has some variables missing - or some additional variables. Missing variables will be set to missing, additional variables won't get added.

View solution in original post


All Replies
Solution
‎08-19-2013 07:01 AM
Respected Advisor
Posts: 4,173

Re: SAS Append error

Posted in reply to munitech4u

Re-writing the table is required to add or remove variables from a SAS table. This is something you can achieve with a data step and a set statement or with a SQL statement.

Proc Append "only" concatenates a new data set to an existing base table. The base table does not get re-written - and that's why Proc Append is so efficient. But: Because the base table does not get re-written you also can't add or remove variables from it.

The FORCE option allows you to append a new data set even if it has some variables missing - or some additional variables. Missing variables will be set to missing, additional variables won't get added.

Super Contributor
Posts: 644

Re: SAS Append error

Posted in reply to munitech4u

If the second table has the same data columns in the same order as the first (plus any additional columns), despite not having the same names, you can achieve the append using a SQL set operation, which uses only the column position.

It won't work if second table is missing one of the columns in the first table.

See Base SAS(R) 9.2 Procedures Guide

and the example

proc sql;

    title 'ME1 and ME2: UNION';

     select * from me1

     union

     select * from me2

;

Richard

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 247 views
  • 0 likes
  • 3 in conversation