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

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 942 views
  • 0 likes
  • 3 in conversation