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 !
Question about STATA RDROBUST command usage (Regression Discontinuity Design)I am using the Stata rdrobust command for RDD analysis, aiming to perform a two-stage analysis. The …
t-tests under heteroskedasticityHi everyone, I am trying to analyse how the variable "score" varies over time. I have used the follo…
How to repeat specific observations in panel dataHello everybody I hope you are doing well. I want to repeat observations for one group into other g…
Question about optimal bandwidth selection command in STATA: rdbwselect for RDD testI am using optimal bandwidth selection: mserd using STATA command rdbwselect. I am then providing th…
Cannot get mm_root to solve an equation for which excel shows there is an answerDear Statalist, I have been trying to solve for r in the function described below. I cannot figure …
Subscribe to:
Post Comments (Atom)
0 Response to Extracting two dates. HELP !
Post a Comment