Vertical Join

Reply
Occasional Contributor
Posts: 10

Vertical Join

Hi,

I've got a question concerning a vertical join of two data sets:

I want to append to data set A the data set B. Data set B contains some observations that already exist in data set A. So I want only append the observations that are not already in A. Can you tell me, what's the best way to do this?

Thanks a lot in advance.

Kathrin

Super User
Posts: 17,750

Re: Vertical Join

Update statement

Or an insert with a not exist clause using SQL

Super Contributor
Posts: 578

Re: Vertical Join

If you don't mind creating a new dataset:

proc sql;

create table want as

select * from datasetA

union

select * from datasetB;

quit;

Frequent Contributor
Posts: 81

Re: Vertical Join

Hi,

Please find the code:-

==============================================

data one;

input a b$;

cards;

1 usa

2 india

3 austria

4 africa

;

run;

data two;

input a b$;

cards;

5 brazil

6 norway

1 usa

2 india

4 africa

;

run;

proc sort data=one;by a;run;

proc sort data=two;by a;run;

data final;

merge one two;

by a;

run;

proc print data=final noobs;

run;

Output:-

=====

                                                            a    b

                                                            1    usa   

                                                            2    india 

                                                            3    austria

                                                            4    africa

                                                            5    brazil

                                                            6    norway

===========

==========================================

/Daman

Ask a Question
Discussion stats
  • 3 replies
  • 746 views
  • 1 like
  • 4 in conversation