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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.