Help using Base SAS procedures

Copy rows in 1 table to another table

Reply
Regular Contributor
Regular Contributor
Posts: 238

Copy rows in 1 table to another table

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;

Super User
Posts: 17,784

Re: Copy rows in 1 table to another table

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;

Frequent Contributor
Posts: 95

Re: Copy rows in 1 table to another table

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

Ask a Question
Discussion stats
  • 2 replies
  • 288 views
  • 0 likes
  • 3 in conversation