I need to calculate difference of two dates in different format. At time point 1 (earlier date) has 3 variables "B29" for month, of type "Number", Length 8, Format Best12., Informat F12., which shows value in the form of "1" through "12", representing month: January through December. "B29_B" for day, of type "Number", Length 8, Format Best12., Informat F12., which shows value in the form of "1" through "31", representing days. "B29_C" for year, of type "Number", Length 8, Format Best12., Informat F12., which shows value in the form of "1990" through "2016", representing years. At time point 2 (later date) has just 1 variable "ENDDATE", type "Text", Length 48, Format $F48., Informat $48., which shows value in the form of "20160125", for example. Question 1 So to combine the 3 variables at time point 1 to be 1 variable in the same form of the variable "ENDDATE", which SAS function should be the best? Or should they (both time point 1 and time point 2 variables) be both converted to a third format? Will the codes below be good? Or needs to be modified or changed to a better approach? data want; set have; date=input(catx("",month,day,year),mmddyy10.); format date mmddyy10.; run; Question 2 To calculate difference of two columns of dates after conversion in the same format, which SAS function should be the best? I found DATDIF and INTCK, but don't know which or if there's a better way to proceed, based on the ideal date format to be chosen in my question 1 above. If I try to adapt the codes below, should the changes be just the variable names? data _null_; sdate="12mar1998"d; edate="12jun2008"d; days=intck(‘days’,sdate,edate); put days; run; data _null_; sdate="12mar1998"d; edate="12jun2008"d; days=datdif(sdate,edate,'act/act'); put days; run; Thanks!
... View more