I have two tables- have1 and have 2 and would like to append them. Basically keep observations from both tables and sort them first based on ID and second based on YEAR. Do you guys know the SAS SQL code for this append/merge? I prefer SQL and not data step code. Thanks.
Have1 | ||
ID | State | YEAR |
1 | AR | 1989 |
1 | AR | 1990 |
1 | AR | 1991 |
1 | AR | 1992 |
1 | AR | 1993 |
1 | AR | 1994 |
2 | OK | 1995 |
2 | OK | 1996 |
2 | OK | 1997 |
2 | OK | 1998 |
Have2 | ||
ID | State | YEAR |
1 | CA | 1999 |
1 | CA | 2000 |
1 | CA | 2001 |
1 | CA | 2002 |
1 | CA | 2003 |
2 | NV | 1999 |
2 | NV | 2000 |
2 | NV | 2001 |
2 | NV | 2002 |
2 | NV | 2003 |
Want | ||
ID | State | YEAR |
1 | AR | 1989 |
1 | AR | 1990 |
1 | AR | 1991 |
1 | AR | 1992 |
1 | AR | 1993 |
1 | AR | 1994 |
1 | CA | 1999 |
1 | CA | 2000 |
1 | CA | 2001 |
1 | CA | 2002 |
1 | CA | 2003 |
2 | OK | 1995 |
2 | OK | 1996 |
2 | OK | 1997 |
2 | OK | 1998 |
2 | NV | 1999 |
2 | NV | 2000 |
2 | NV | 2001 |
2 | NV | 2002 |
2 | NV | 2003 |
UNION ALL
See the docs re Combining Datasets.
UNION ALL
See the docs re Combining Datasets.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.