Dear community,
I have a dataset with one variable entrydate (dd.mm.yyyy; format str10; all in 2019 or 2020) and one variable entrytime (hh:mm; format str5; 24h format). I also have exitdate and exittime variables of the same type. I'd now like to generate entrydatetime and exitdatetime variables to be used in survival analysis.
After having tried several solutions from this forum, I got as far as this:
I don't get any error code. However, dentrydate is displayed correctly (same way as entrydate to the human eye), but dentrytime and entrydatetime are only displayed as "."
What do I need to change in order to correctly display entrydatetime as DMY HH:MM? I'd like to be able to calculate differences of exitdatetime-entrydatetime for my survival analysis.
Many thanks in advance for Your advice.
I have a dataset with one variable entrydate (dd.mm.yyyy; format str10; all in 2019 or 2020) and one variable entrytime (hh:mm; format str5; 24h format). I also have exitdate and exittime variables of the same type. I'd now like to generate entrydatetime and exitdatetime variables to be used in survival analysis.
After having tried several solutions from this forum, I got as far as this:
Code:
generate double dentrydate = date(entrydate,"DMY") generate double dentrytime = clock(entrytime,"hms") format dentrydate %tdDD/NN/CCYY format dentrytime %tcHH:MM generate double entrydatetime=dentrydate*24*60*60*1000+dentrytime format entrydatetime %tcDD/NN/CCYY_HH:MM
What do I need to change in order to correctly display entrydatetime as DMY HH:MM? I'd like to be able to calculate differences of exitdatetime-entrydatetime for my survival analysis.
Many thanks in advance for Your advice.

Comment