BookmarkSubscribeRSS Feed
Fry
Calcite | Level 5 Fry
Calcite | Level 5

Hi, I need your help solving this issue:

I have client_id with multiple date of service and I need to place in between the correct range of dates, the date that client make a payment, so for example:

 

Table 1

Client        DateOf Service

m1256          5/2/2013

m1256           7/4/2013

m1256           11/1/2014

m1256           5/11/2015

k5678             3/4/2016

k5678             8/16/2017

r2983            5/6/2015

r2983            12/22/2015

r2983             4/29/2016

 

table2.  Payments

Client         Payment

m1256       5/16/2013

m1256       6/28/2016

k5678        5/14/2016

k5678        7/23/2016

r2983        7/3/2015

r2983        3/1/2016

r2983        5/23/2016

 

I think I can rank the dates in table 1 and stablish start and end date, maybe?   Any help will be awesome!

2 REPLIES 2
PaigeMiller
Diamond | Level 26

You could just append the two data sets and then sort by client and date.

--
Paige Miller
Astounding
PROC Star

All your dates need to be actual SAS dates, not text strings.

 

And your data sets need to be in sorted order.

 

With those conditions in place, this would be one way to rearrange the pieces:

 

data want;

set table1 (rename=(DateofService=Date) in=in1)

   table2 (rename=(Payment=Date) in=in2);

by Client Date;

if in1 then Action='Service';

else Action='Payment';

run;

 

Try it, see if you like what you get.  (If you don't like it, you might have to design what you would like the solution to look like before programming can begin.)

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 306 views
  • 2 likes
  • 3 in conversation