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
Cannot Install didregress commandHi all, I am trying to run a regression like the follwoing one: Code: didregress (satis) (procedu…
plot the results of a 2sls regression with fixed effectsHello, I want to plot the results of a 2sls regression with fixed effects for different values of a …
Test with weighted regressionI am running a simple weighted regression as follows: reghdfe y i.treatment [weight=size], noa vce(…
Replace when a string variable is longer than 4 charactersDear all, I would like to replace a string variable which is longer than 4 digits with numbers. For…
estab problemsHello forum I am having a problem using -estab- to create an rtf.table output for some tabstats. I …
Subscribe to:
Post Comments (Atom)
0 Response to Datetime variable
Post a Comment