Hello
I have a database of visitors to a clinic. Each visitor has an id and I have made the variable dup which numbers each visitor's visits in chronological order.
I want to create the variables datefirst, datesecond etc. which give the date of the first visit, second visit etc. so that each case would contain all of the information on dates of visitors' visits.
I tried the below but it is not working. Any help much appreciated.
bysort id (dup) : gen datefirst = dateofvisit[1]
bysort id (dup) : gen datesecond = dateofvisit[2]
bysort id (dup) : gen datethird = dateofvisit[3]
bysort id (dup) : gen datefourth = dateofvisit[4]
I have a database of visitors to a clinic. Each visitor has an id and I have made the variable dup which numbers each visitor's visits in chronological order.
I want to create the variables datefirst, datesecond etc. which give the date of the first visit, second visit etc. so that each case would contain all of the information on dates of visitors' visits.
I tried the below but it is not working. Any help much appreciated.
bysort id (dup) : gen datefirst = dateofvisit[1]
bysort id (dup) : gen datesecond = dateofvisit[2]
bysort id (dup) : gen datethird = dateofvisit[3]
bysort id (dup) : gen datefourth = dateofvisit[4]
Comment