Here is the exam data table that I would like to process here:
-origin data
–a table
STU_ID | STU_KEY | STU_CODE_1 |
---|---|---|
123 | 2002123 | A121 |
124 | 2002124 | A122 |
125 | 2002125 | A123 |
126 | 2002126 | A124 |
–b table |STU_ID|STU_KEY|STU_CODE_2| |——|——-|———-| |123 |2002223|B121 | |124 |2002224|B122 | |125 |2002225|C123 | |126 |2002226|C124 | |127 |2002127|C125 |
I want to merge between ‘a’ and ‘b’ tables using code of SAS proc sql as follows.
-result data merge table
STU_ID | STU_KEY | STU_CODE_1 | STU_CODE_2 |
---|---|---|---|
123 | 2002123 | A121 | |
123 | 2002223 | B121 | |
124 | 2002124 | A122 | |
124 | 2002224 | B122 | |
125 | 2002125 | A123 | |
125 | 2002225 | C123 | |
126 | 2002126 | A124 | |
126 | 2002226 | C124 | |
127 | 2002127 | C125 |
'''error code'''
PROC SQL;
CREATE TABLE a_b_merge as
SELECT t1.STU_ID,
t1.STU_KEY,
t1.STU_CODE_1
t2.STU_CODE_2
FROM a as t1 full join b as t2
ON t1.STU_ID=t2.STU_ID
QUIT;
Let me know how to solve this problem.