I have two tables and one of them I want to copy all the data into the base table. both tables have same rows, column headers and all.
The base table called X has 5798 rows with 9 columns and the table I want to copy to this base table is table Y and has 94 rows with 9 columns. I want to take table Y and copy all the data into table X. I tried append but since the primary key is the same even using the force did not work. It comes back and says it was successful yet then says final outcome is 5798 rows. I never says 5892 rows.
proc append base = y data = x force;
run;
Show the log from the following code:
proc append base=x data=y force;
run;
proc sql;
create table new_selection as
(select * from x
union all
select * from y) b;
quit;
Do you have a unique index on the data set X? Can you run a proc contens on the data set X and share the log with us?
If so and Y data set has observations that match the key variable values in data set X it will reject those observations in Y when appended.
data class;
set sashelp.class;
run;
proc sql;
create unique index Name on class ;
quit;
proc contents data=class; run;
proc append base=class data=sashelp.class;
run;
NOTE: Appending SASHELP.CLASS to WORK.CLASS.
WARNING: Duplicate values not allowed on index Name for file CLASS, 19 observations rejected.
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: 0 observations added.
NOTE: The data set WORK.CLASS has 19 observations and 5 variables.
NOTE: PROCEDURE APPEND used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.