Link to home
Start Free TrialLog in
Avatar of aruku
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.
Avatar of bradanelson
bradanelson
Flag of United States of America image

Depending on the desired outcome, the joins may change.  Are you wanting to keep all records in a particular dataset even if they don't match a joining dataset?  Or, are you just wanting to keep the records where they match the joining datasets?

Example of code to join all datasets, keeping all records in dataset a.
PROC SQL;
    CREATE TABLE merged AS
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;
ASKER CERTIFIED SOLUTION
Avatar of bradanelson
bradanelson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial