I have observations where the data was saved as csv files and now loaded into stata.
There is the 1) inclusion date =trial date and 2) echo_date= a date where we did an ultrasound of the heart (echocardiogram) on a subgroup of participants.
The trial date is not the same for all participant, it can be, but not always.
As the echo test should not be older than 1 year or 365 days from the trial_date. So I tried to change the format of the dates from strings to date, but then I am stuck.
I don't know how to extract them from each other.
generate echo_date = date(ek_echo_date, "YMD")
format %tdCCYY-NN-DD echo_date
generate trial_date = date(sp_date, "YMD")
format %tdCCYY-NN-DD trial_date
AND now to extract
drop if trial_date > 365 ... echo_date ?
My supervisor has a windows laptop while I use MAC, he has used the following commands, and it works for him
replace ek_echo_date = date("19apr2015","DMY") if sp_cpr1=="020843xxxx"
gen = (ek_echo_date-sp_date)
sort screen_echo_time
cpr is the personal id number and it is not xxxx we use in the command, it is actual numbers, but I had to hide here.
As I understand he puts one specific participant as the "start point" and then says if the date is 1 year older than that then we drop the echo, but I get "type mismatch"
Thank you very much in advance.
Best regards Lida
Related Posts with Extracting two dates. HELP !
Chow test for structural break in 2SLS processI am using ivregress in STATA 16. I want to understand how can I apply chow test for structural brea…
Omitted variables of collinearityI have omitted variables problem when I run linear regression with lag(1). However, I do not have pr…
how to choose between Fixed effects model and Pooled OLS model ?hello everyone, i'm currenlty doing a research for my masters' thesis, and i'm doing a panel study o…
Creating a lag variableHi Stata Users I am using Stata version 15 on a dataset with about 900,000 observations. I would lik…
Chow test for structural brake in 2SLS processI am using ivregress in STATA 16. I want to understand how can I apply chow test for structural brea…
Subscribe to:
Post Comments (Atom)
0 Response to Extracting two dates. HELP !
Post a Comment