Help using Base SAS procedures

proc append certain fields

Reply
Regular Contributor
Regular Contributor
Posts: 238

proc append certain fields


I have looked and looked and cannot find how to append just certain fields of a table. I normally append by doing this:

proc append data=base_table data=&tbl_nm  force;

> run;

But in this case I want to append only 2 fields. The base table had the same fields, label and dataset as the data I am appending.

The base table looks like this:

sys_cd         sys_desc     amount1     amount2     amount3     amount4

1                     jason            1                   1                   1                1

2                     john              2                   2                    2               2

3                     sara              3                  3                     3                3

the data table looks like this:

sys_cd            sys_desc

4                    sue

5                    michael

6                     linda

I just want to append the above to the base but because the base has amount stuff and the other does not it does not work and just does everything when I append as null values even for the sys_cd and sys_desc

Super Contributor
Posts: 1,636

Re: proc append certain fields

have you tried adding option force?

Super User
Posts: 19,815

Re: proc append certain fields

Your code is incorrect, it should be

BASE= and DATA=

not two DATA= statements.

proc append base=base_table data=&tbl_nm  force;

run;

Super Contributor
Posts: 356

Re: proc append certain fields

There is an issue in your append ie have two data's

try

data base;

infile datalines delimiter=',';

input sys_cd   sys_desc $     amount1     amount2     amount3     amount4 ;

datalines;

1,jason,1,1,1,1

2,john,2,2,2,2

3,sara,3,3,3,3

;

run;

data data;

infile datalines delimiter=',';

input sys_cd   sys_desc $     ;

datalines;

4,sue 5,michael

6,linda

;

run;

proc append base=base data=data  force; run;

Frequent Contributor
Posts: 118

Re: proc append certain fields

Hey...

Have you tried after correcting your codes as all suggestion above ?

You may also refer to below one for more info :Why We Use FORCE Option In PROC APPEND To Upload Data To Data Warehouse ~ SAS Certification prep and...

Regards

Uma Shanker Saini

Super User
Posts: 10,035

Re: proc append certain fields

Your can try:

proc append data=base_table(keep=sys_cd         sys_desc ) data=&tbl_nm(keep=sys_cd         sys_desc ) force;run;


OR


proc sql;

create table want as

select * from base_table

union all corr

select * from &tbl_nm

;

quit;


Xia Keshan

Super User
Super User
Posts: 7,963

Re: proc append certain fields

Another method:

proc sql;

  insert into BASE_TABLE (SYS_CD,SYS_DESC)

  select  *

  from    DATA_TABLE;

quit;

Ask a Question
Discussion stats
  • 6 replies
  • 562 views
  • 0 likes
  • 7 in conversation