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 !
Failing to convert .shp and .dbf dile to .dta formatHello, I'm trying to convert a gis file to .dta format. To answer a few questions: .shp and .dbf ar…
chnaging values of a variableDear Listers, I am using Stata 15.1. I am working with a dataset with more than a million observati…
Panel Data fixed effects and time effectsHello there, For my master thesis I am conducting research about the effects of the digital divide o…
Question on metacumboundsHi everyone, I would like to seek advice on the metacumbounds package used for trial sequential ana…
Populating a column with valuesI need to populate the empty columns with corresponding values within that year, it could be that I …
Subscribe to:
Post Comments (Atom)
0 Response to Extracting two dates. HELP !
Post a Comment