03-27-2017 08:45 PM
Total_DOB = input(catx("/", month_dob, day_dob, year_dob),?? mmddyy8.);
if ((month_dob = 29) AND (day_dob= 02)) then Total_DOB = mdy(03,01,year_dob)-1;
else Total_DOB = mdy(month_dob,15,year_dob);
03-27-2017 09:31 PM
I would try the below approach if there are only two conditions
1) if the month_dob=02 and day_dob=29 then you want it to be imputed to 01MarYYYY. imputing only the day and month. if it is the case then what you mentioned is incorrect, you codes month_dob=29 which should be 02 as i mentioned so you reversed it.
2) if the above condition is not met then you would like to impute only the day to 15.
Please let me know if these are only two conditions you are checking.
03-27-2017 10:23 PM
Let's start with the most obvious issues and clear them up. There might be more, but start with ...
Is YEAR_DOB really a two-digit year? That would be the only reason to use ?? MMDDYY8. But if YEAR_DOB is really a four-digit year, MMDDYY8 isn't long enough. You need to switch to MMDDYY10. because you have to count the slashes as part of the characters you are reading.
It looks like you have switched around the month and the day. It is highly unlikely that you will ever find MONTH_DOB=29.
03-28-2017 12:15 AM
Did you know that function MDY can handle two digits year values? If the problem is that you are sometimes missing the day value, then all you need is:
Total_DOB = mdy (month_dob, coalesce(day_dob, 15), year_dob);
format total_DOB yymmdd10.;
03-28-2017 07:27 AM
First of all, are month_dob, day_dob, year_dob numeric or character? In your code snippet you treat them as both, which is at least not sound programming practice.
Assuming that they are numeric, I'd do
Total_DOB = input(put(year_dob,z4.) !! put(month_dob,z2.) !! put(day_dob,z2.),yymmdd8.); if Total_DOB = . then do; if ((month_dob = 29) and (day_dob = 2)) then Total_DOB = mdy(3,1,year_dob)-1; else if day_dob = . then Total_DOB = mdy(month_dob,15,year_dob); end;