aruku
asked on
Please help me solve this senario in sas
I have 4 datasets
a ,b , c, d
a
there are four variables
b
there are two variables
c
there is one variable
d
there is one variable
I need to merge these datasets to get a final dataset
There is a common variable between a and b
Common variable between b and c
So I am thinking of merging a and b with the common variable to get temporary dataset e
and use the common variable of b to merge e and c to get the temporary dataset n
and merge n with d using the common variable between b and d to get final dataset g
Is this process correct to see that the data is not shuffled.
a ,b , c, d
a
there are four variables
b
there are two variables
c
there is one variable
d
there is one variable
I need to merge these datasets to get a final dataset
There is a common variable between a and b
Common variable between b and c
So I am thinking of merging a and b with the common variable to get temporary dataset e
and use the common variable of b to merge e and c to get the temporary dataset n
and merge n with d using the common variable between b and d to get final dataset g
Is this process correct to see that the data is not shuffled.
Sorry, here is the code...
PROC SQL;
CREATE TABLE merged AS
SELECT a.*, b.*, c.*, d.*
FROM a
LEFT JOIN b
ON a.key=b.key
LEFT JOIN c
ON b.id=c.id
LEFT JOIN d
ON b.id=d.id;
QUIT;
PROC SQL;
CREATE TABLE merged AS
SELECT a.*, b.*, c.*, d.*
FROM a
LEFT JOIN b
ON a.key=b.key
LEFT JOIN c
ON b.id=c.id
LEFT JOIN d
ON b.id=d.id;
QUIT;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Example of code to join all datasets, keeping all records in dataset a.
PROC SQL;
CREATE TABLE merged AS