Hello
I am using proc append
In resulted data set I see also column Y.
My question is why?
I chose only columns X,ID so why also appear Y?
Data tbl1;
Input ID X Y;
cards;
1 10 30
2 20 40
;
Run;
Data tbl2;
Input ID X W;
cards;
1 70 90
2 60 60
;
Run;
proc append base=tbl1(Keep=ID X) data=tbl2(Keep=ID X) ;
run;
proc print data=tbl1 noobs;Run;
Read the help first.
It is well written.
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p1bjrbc5esr90on12o8vs7gyv8ue.htm
If you use the DROP=, KEEP=, or RENAME= options on the BASE= data set, the options affect ONLY the APPEND processing and does not change the variables in the appended BASE= data set. Variables that are dropped or not kept using the DROP= and KEEP= options still exist in the appended BASE= data set. Variables that are renamed using the RENAME= option remain with their original name in the appended BASE= data set.
Try:
Data tbl1;
Input ID X Y;
cards;
1 10 30
2 20 40
;
Run;
Data tbl2;
Input ID X W;
cards;
1 70 90
2 60 60
;
Run;
proc append base=tbl1_ALL data=tbl1(Keep=ID X) ;
run;
proc delete data = tbl1;
run;
proc append base=tbl1_ALL data=tbl2(Keep=ID X) ;
run;
proc print data=tbl1_ALL noobs;Run;
B.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.