Help using Base SAS procedures

Lookup date

Reply
N/A
Posts: 1

Lookup date

Hi everyone, hoping someone could assist me with a SAS statement to produce an output I'm after.

I have two separate datasets as below:

Policy ClaimDate

ABC    Jan 2012

ABC    Aug 2012

ABC    Jul 2014

Policy RenewalDate

ABC   Sep 2012

ABC   Sep 2013

ABC   Sep 2014

For this policy, I'm trying to group the ClaimDate into the RenewalDate. For example, if the claim is pre Sep 2012, I would like to group it into Sep 2012. If the claim is between Oct 2012 and Sep 2013, I would like to group it into Sep 2013.. and so forth.

The final output would be something like this:

Policy ClaimDate RenewalDate

ABC   Jan 2012    Sep 2012

ABC   Aug 2012   Sep 2012

ABC   Jul 2014    Sep 2014

Thanks in advance!

-zorro3338

Respected Advisor
Posts: 3,124

Re: Lookup date

Your rules needs to more specific given your example, what happens when both Aug2012 and Jan2012 is prior to Sep2012 in both rows? what happens to Sep 2013 renewaldate?  How do you determine which goes to which?

Super User
Posts: 9,687

Re: Lookup date

data want;

merge A B ;

run;

??

Super User
Posts: 17,870

Re: Lookup date

Sounds like you the September that's in the future.

Assuming SAS Dates, since you haven't specified, something like the following:

*claimDate=input(claim_date, yearmon7.); *if claim_date is a character variable can be converted using the input function;

if month(claimDate)<=9 then RenewalDate=mdy(9,1, year(claimDate));

else RenewalDate=mdy(9,1, year(claimDate)+1);

Format renewalDate monyy7.;

Ask a Question
Discussion stats
  • 3 replies
  • 191 views
  • 0 likes
  • 4 in conversation