Dear ALL,
I have a data set where some patients have more than one entry (visit) i.e. same patient with different visit dates, while some have only one entry (visit). I would like to select only the first visit from each patient (The variables to use are id_unique and visit_date)
Regards
Walter
Hi. I cannot give you the comand syntax in epidata (maybe in Stata) but what you could simply do is the following: Create a variable first_visit_date = min(visit_date) by (id_unique) select where visit_date = firs_visit_date.
Serge
2014-09-29 14:41 GMT+02:00 epidata-list@lists.umanitoba.ca:
Dear ALL,
I have a data set where some patients have more than one entry (visit) i.e. same patient with different visit dates, while some have only one entry (visit). I would like to select only the first visit from each patient (The variables to use are id_unique and visit_date)
Regards
Walter _______________________________________________ EpiData-list mailing list EpiData-list@lists.umanitoba.ca http://lists.umanitoba.ca/mailman/listinfo/epidata-list
In analysis just do this: read "your datafile name" sort idunique visitdate gen i number = 1 if idunique = idunique[_n-1] then number = number[_n-1] + 1
* now you have a variable "number", which gives the sequence of observations for each person.
select number = 1 * will now make sure you only analyse the first observation.
You may also use the commands aggregate, but there would be a problem (as I remember it) with dates, which are then just integers and no longer dates.
regards Jens Lauritsen EpiData Association
Den 29. sep. 2014, epidata-list@lists.umanitoba.ca skrev:
Hi. I cannot give you the comand syntax in epidata (maybe in Stata) but what you could simply do is the following: Create a variable first_visit_date = min(visit_date) by (id_unique) select where visit_date = firs_visit_date.
Serge
2014-09-29 14:41 GMT+02:00 <epidata-list@lists.umanitoba.ca>:
Dear ALL,
I have a data set where some patients have more than one entry (visit) i.e. same patient with different visit dates, while some have only one entry (visit). I would like to select only the first visit from each patient (The variables to use are id_unique and visit_date)
Regards
Walter _______________________________________________ EpiData-list mailing list EpiData-list@lists.umanitoba.ca http://lists.umanitoba.ca/mailman/listinfo/epidata-list
-- *M. Aymar Serge SOMDA, BEng. MMath. MSPH.* *Méthodologiste - Biostatisticien*
Chef Unité de Formation et d'Appui Méthodologique Centre MURAZ Bur: (226) 20 97 01 02 Poste 438 GSM: (226) 70 44 33 22 Bobo Dioulasso, Burkina Faso Email: serge.somda@centre-muraz.bf http://www.centre-muraz.bf/
Cellule de Biostatistique Institut Universitaire du Cancer Toulouse - Oncopole Bur: (33) (0)531 155 860 GSM: (33) (0)604 521 773 Toulouse, France Email: somda.serge@iuct-oncopole.fr http://www.oncopole-toulouse.com/
EpiData-list mailing list EpiData-list@lists.umanitoba.ca http://lists.umanitoba.ca/mailman/listinfo/epidata-list
In Epidata Analysis, do this: (I’m using id and visit - you cannot have names with underscores in classic Epidata and it is probably not a good idea in new Epidata)
define vfirst # vfirst = 1 sort id visit if id = id[recnumber-1] then vfirst = 0 select vfirst=1
id[recnumber-1] refers to the value of id in the previous record. Since the data are sorted first by id and then visit, this will leave vfirst=1 whenever id changes.
Jamie
On Sep 29, 2014, at 8:41 AM, epidata-list@lists.umanitoba.ca wrote:
Dear ALL,
I have a data set where some patients have more than one entry (visit) i.e. same patient with different visit dates, while some have only one entry (visit). I would like to select only the first visit from each patient (The variables to use are id_unique and visit_date)
Regards
Walter _______________________________________________ EpiData-list mailing list EpiData-list@lists.umanitoba.ca http://lists.umanitoba.ca/mailman/listinfo/epidata-list
participants (1)
-
epidata-list@lists.umanitoba.ca