BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

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;
 
2 REPLIES 2
japelin
Rhodochrosite | Level 12

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.

 

 

yabwon
Amethyst | Level 16

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.

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 829 views
  • 2 likes
  • 3 in conversation