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 .

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 507 views
  • 0 likes
  • 3 in conversation