I have three tables and I want to vertically merge those tables
I want to combine these tables into single table like this using proc sql so that I can save the table:
Name Money_1 Money_2 Money_3
X 2000 600 0
Y 4000 0 8000
Z 0 400 600
Like this I have 50 tables and I want to merge them vertically using proc sql
One solution is joining two tables at once using full join but in select statement choose the Name variable of table with the most rows. That works for few tables but i have over 50 tables and I need a feasible solution to this problem
There is no "vertical merge". You can either stack datasets vertically, or join/merge them horizontally.
What you want can be most simply achieved by first stacking, with an interleave, and then transposing:
length dname $41 dsname $32;
dsname = scan(dname,2,"."); /* removes library name */
With additional logic in the data step, you can create variable names for the transpose to your liking.
The only thing that should be automated is the list of dataset names for the SET statement. You can use a colon wildcard there (lib.table:), or retrieve the list from DICTIONARY.TABLES in SQL into a macro variable.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.