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

Hi. I am trying to merge 2 datasets by ID and based on quarterly date range. How can I do this?

 

 

What I have:

 

ID             Date                 

1111        01/01/2018

2222        04/03/2018

etc              etc

 

ID             Amount 01/012018-03/31/2018   Amount 04/01/2018-07/30/2018     etc         

1111        $1                                                     $2

2222       $3                                                       $4

etc              etc                                                 etc

 

 

What I want:

 

ID             Date                   Amount for that period

1111        01/01/2018            $1  

2222        04/03/2018             $4

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

That data is not presented in a way which is useful for us.  Please post a datastep with some test data so we have something that actually represents the data that we can run:

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 

I can provide some tips however:

1) Re-model dataset 2, it is rarely a good idea to have wide (transposed) datasets, and will make your code far more complex and less robust.  Remodel to:
ID  START   END   AMOUNT

 

In this way your merge will become a lot simpler.

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

That data is not presented in a way which is useful for us.  Please post a datastep with some test data so we have something that actually represents the data that we can run:

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 

I can provide some tips however:

1) Re-model dataset 2, it is rarely a good idea to have wide (transposed) datasets, and will make your code far more complex and less robust.  Remodel to:
ID  START   END   AMOUNT

 

In this way your merge will become a lot simpler.

Ksharp
Super User

" Amount 01/012018-03/31/2018" is not real or validate sas variable name.

Post your real variable name .

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
  • 2 replies
  • 981 views
  • 0 likes
  • 3 in conversation