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
have you tried adding option force?
Your code is incorrect, it should be
BASE= and DATA=
not two DATA= statements.
proc append base=base_table data=&tbl_nm force;
run;
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;
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
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
Another method:
proc sql;
insert into BASE_TABLE (SYS_CD,SYS_DESC)
select *
from DATA_TABLE;
quit;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.