Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: R: Summarising multiple visit data for each individual participant

From   <[email protected]>
To   <[email protected]>
Subject   st: R: Summarising multiple visit data for each individual participant
Date   Fri, 2 Mar 2012 16:51:37 +0100

Dear Matthew,
I would contrast those patients who did not switch to other antibiotic vs
those who did (please, see below):
------------------code begins------------------------------------
drop _all
set obs 100
g id=_n
g V_1=1 in 1/33
replace V_1=1 in 90/100
replace V_1=2 if V_1==.
g V_2=1 in 1/30
replace V_2=2 if V_2==.
g V_3=1 in 1/50
replace V_3=2 in 51/100
g infection=1 in 1/30
replace infection=0 in 31/80
replace infection=1 in 81/100
g No_switch = 1 if V_1== V_2==V_3
replace No_switch = 0 if No_switch==.
g time_0=0
g time_exit=1 in 81/100
replace time_exit=2 in 1/30
replace time_exit=3 if time_exit==.
g risk_time= time_exit- time_0
stset risk_time, failure(infection==1)
stcox No_switch

HTH and Kindest Regards,

-----Messaggio originale-----
Da: [email protected]
[mailto:[email protected]] Per conto di Matthew Hurley
Inviato: venerdì 2 marzo 2012 15:45
A: [email protected]
Oggetto: st: Summarising multiple visit data for each individual participant

Dear all,
I would be grateful for your help as I cannot find a solution in the
archives or online.

I have patient registry data for which visit data is grouped by patient ID.
At each visit individuals are administered an antibiotic.  I wish to
determine if specific antibiotic usage in this dataset is associated with
infection in a survival analysis.

I have completed the survival analysis assuming that the antibiotic taken on
the first visit represents all antibiotic taken throughout the period,
however this assumption is incorrect as antibiotic usage changes on some

Is there a way I can 'summarise' each individual patients antibiotic use
please?  The most pragmatic solution I can think of is to perform a
sensitivity analysis for those patients whose antibiotic usage does not
change (e.g. for the first 3 visits) to see if this changes my results.

I have tried by generating an indicator variable 'visitno'. 'chrpo' is my
categorical variable that reports the antibiotic taken at each visit -
generating a 'sumabx' variable that reports the consistently administered
antibiotic for each patient.

by ID ( visitno), sort: gen sumabx = chrpo if chrpo[1]== chrpo[2]== chrpo[3]
....however this doesn't work.
I have a separate indicator variable that selects the first visit per

Apologies if this is a really rudimentary question that highlights my
ignorance, but I genuinely cannot find the solution anywhere.

Best wishes,
Clinical Research Fellow
University of Nottingham
This message and any attachment are intended solely for the addressee and
may contain confidential information. If you have received this message in
error, please send it back to me, and immediately delete it.   Please do not
use, copy or disclose the information contained in this message or in any
attachment.  Any views or opinions expressed by the author of this email do
not necessarily reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index