[EpiData-list] RE: EpiData-list Digest, Vol 130, Issue 7 - count number of records

epidata-list at lists.umanitoba.ca epidata-list at lists.umanitoba.ca
Mon Sep 29 12:26:21 CDT 2014


Hi Walter,

You could create a count of the number of records per unique individual and then select the first record:

Sort idunique visitdate

gen i count = 1
	Var Name count of type Integer and length: 9 decimals 0
 if idunique = idunique[_n-1] then count= count[_n-1] + 1
 count= count[_n-1] + 1
	 the [_n] indicates recnumber and by subtracting one "_n-1" we get the previous record

select if count=1

Hope this helps,

Renate 

-----Original Message-----
From: epidata-list-bounces at lists.umanitoba.ca [mailto:epidata-list-bounces at lists.umanitoba.ca] On Behalf Of epidata-list-request at lists.umanitoba.ca
Sent: Monday, September 29, 2014 1:01 PM
To: epidata-list at lists.umanitoba.ca
Subject: EpiData-list Digest, Vol 130, Issue 7

Send EpiData-list mailing list submissions to
	epidata-list at lists.umanitoba.ca

To subscribe or unsubscribe via the World Wide Web, visit
	http://lists.umanitoba.ca/mailman/listinfo/epidata-list
or, via email, send a message with subject or body 'help' to
	epidata-list-request at lists.umanitoba.ca

You can reach the person managing the list at
	epidata-list-owner at lists.umanitoba.ca

When replying, please edit your Subject line so it is more specific than "Re: Contents of EpiData-list digest..."


EpiData-list mailing list
___________________________________

Today's Topics:

   1. (no subject) (epidata-list at lists.umanitoba.ca)
   2. Re: (no subject) (epidata-list at lists.umanitoba.ca)
   3. Re: first observation among several for each person	(no
      subject) (epidata-list at lists.umanitoba.ca)
   4. Re: (no subject) (epidata-list at lists.umanitoba.ca)


----------------------------------------------------------------------

Message: 1
Date: Mon, 29 Sep 2014 15:41:17 +0300
From: epidata-list at lists.umanitoba.ca
Subject: [EpiData-list] (no subject)
To: epidata-list at lists.umanitoba.ca
Message-ID:
	<CAMLtmTBnDMV9Lrnq2UxM5t9H4Nd9B41aHJULbr1Y5qDL=3NY5Q at mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

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


------------------------------

Message: 2
Date: Mon, 29 Sep 2014 15:56:52 +0200
From: epidata-list at lists.umanitoba.ca
Subject: Re: [EpiData-list] (no subject)
To: epidata-list at lists.umanitoba.ca
Message-ID:
	<CAHDXojvVqiyuSKVToxE4q82DFva6Bv6+bddzpKhxqX7FNbmV1w at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

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 at 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 at 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 at 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 at iuct-oncopole.fr
http://www.oncopole-toulouse.com/

*
*


------------------------------

Message: 3
Date: Mon, 29 Sep 2014 15:26:53 GMT
From: epidata-list at lists.umanitoba.ca
Subject: Re: [EpiData-list] first observation among several for each
	person	(no subject)
To: <epidata-list at lists.umanitoba.ca>
Message-ID: <1412004413115.66366.16794 at webmail5>
Content-Type: text/plain; charset=UTF-8

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 at 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 at 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 at 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 at 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 at iuct-oncopole.fr>
> <http://www.oncopole-toulouse.com/>
> 
> *
> *
> _______________________________________________
> EpiData-list mailing list
> EpiData-list at lists.umanitoba.ca
> <http://lists.umanitoba.ca/mailman/listinfo/epidata-list>
> 


------------------------------

Message: 4
Date: Mon, 29 Sep 2014 11:36:11 -0400
From: epidata-list at lists.umanitoba.ca
Subject: Re: [EpiData-list] (no subject)
To: EpiData List <epidata-list at lists.umanitoba.ca>
Message-ID: <BLU436-SMTP2503B22D35AA5A8742A58E3FDBA0 at phx.gbl>
Content-Type: text/plain; charset="windows-1252"

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 at 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 at lists.umanitoba.ca
> http://lists.umanitoba.ca/mailman/listinfo/epidata-list
> 



------------------------------

________________________________________
EpiData-list at lists.umanitoba.ca
http://lists.umanitoba.ca/mailman/listinfo/epidata-list


End of EpiData-list Digest, Vol 130, Issue 7
********************************************


More information about the EpiData-list mailing list