BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Agent1592
Pyrite | Level 9

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  
IDStateYEAR
1AR1989
1AR1990
1AR1991
1AR1992
1AR1993
1AR1994
2OK1995
2OK1996
2OK1997
2OK1998

 

Have2  
IDStateYEAR
1CA1999
1CA2000
1CA2001
1CA2002
1CA2003
2NV1999
2NV2000
2NV2001
2NV2002
2NV

2003

 

Want   
IDStateYEAR
1AR1989
1AR1990
1AR1991
1AR1992
1AR1993
1AR1994
1CA1999
1CA2000
1CA2001
1CA2002
1CA2003
2OK1995
2OK1996
2OK1997
2OK1998
2NV1999
2NV2000
2NV2001
2NV2002
2NV2003
1 ACCEPTED SOLUTION
1 REPLY 1

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1761 views
  • 0 likes
  • 2 in conversation