Hello,
I converted an Excel File into a Stata File. It concerns data from a website, in which participants monitored their health by filling in a questionnaire. In Stata, every participant has #amount of rows, dependent of how many times they filled in the health-questionnaire (e.g. a participant that filled in the questionnaire 6 times, has 6 rows in stata). I would like to calculate the difference in days between the first and the last time each participant filled in this questionnaire (for more than 3000 participants).
I use a datetime variable that looks like this: 5-09-18 10:00
I have two questions:
- What command should I use to convert this variable from string to date/time? I tried to use clock( var_name ,"DMYhm") but this didn't work.
- What command should I use to calculate the difference between the first and last row? Note that the amount of rows is different for each participant.
Thanks in advance for your reply.
Sophie.
Related Posts with Datetime variable
Calculating Standard Deviation of the ResidualsHi all, I ran an ECM and after this, I want to inspect the Standard Deviation of the Residuals plot …
How to check if variables in varlist are registered as regular or imputedI'm trying to write a loop that iterates through every single variable in a varlist and performs dif…
Endogeneity in non-structural modelingHello Stata users, Can you pleas tell me how we can adress endogeniety in non-structural modeling? …
Create a table with sectoral share valuesDear all, I am currently working with a dataset that contains information on quarterly gross value …
how to run a DEA meta frontière in stata?I want to implement a meta boundary model to take into account the specificity of each group in the …
Subscribe to:
Post Comments (Atom)
0 Response to Datetime variable
Post a Comment