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
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?
data want;
merge A B ;
run;
??
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.;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.