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.
Navigate AI governance with SAS tools for compliance and ethical AI practices. Try SAS Ai Navigator for free for the first six months.
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.
Ready to level-up your skills? Choose your own adventure.