I have individual animal (sheep) plasma concentration data from (~50) sheep taken from a pharmacokinetic study and I would like to produce a dataset of summary PK values for each individual using the pkexamine command, I do not want the overall summary one gets from using pksumm as I want to examine each animal's values. Instead of repeating this manually, oh the tedium!! I thought I could use statsby, however I get the following error messages:
time variable takes on repeated values
an error occurred when statsby executed pkexamine
r(459);
I include a MWE below (between the horizontal lines) I am sure I'm missing something simple, but I can't figure it out. Perhaps statsby and pkexamine don't play well together?
Note I installed the runby package and tried this, but again abject failure
The code is also included below. The message this code elicits is:
--------------------------------------
Number of by-groups = 10
by-groups with errors = 10
by-groups with no data = 0
Observations processed = 70
Observations saved = 0
--------------------------------------
(I am using Stata 15 on Windows 10)
Thanks
john
* Example generated by -dataex-.
clear
input float(id conc0 conc1 conc2 conc4 conc6 conc12 conc24)
80 0 .32 1.68 4.83 5.27 6.48 5.86
91 0 .6 1.97 3.77 3.69 3.23 2.54
104 0 .93 2.5 3.03 2.75 2.54 1.95
114 0 .72 4.11 8.65 8.88 8.76 9.15
117 0 .56 3.94 7.61 8.14 8.2 9.21
124 0 .61 1.66 5.22 5.35 5.42 5.23
130 0 1.51 2.32 3.52 4.18 4.31 3.32
134 0 1.53 3.22 6.56 6.43 9.16 7.41
145 0 .64 4.88 6.76 5.89 6.24 4.13
161 0 .54 3.54 8.63 8.12 8.3 4.19
end
[/CODE]
reshape long conc, i(id) j(time)
statsby cmax=r(cmax) tmax=r(tomc) half=r(half) auc=r(auc) , ///
by(id) nodots clear : pkexamine time conc
capture program drop pk_id
program define pk_id
levelsof id, local(i)
foreach v of varlist `i' {[INDENT=2]pkexamine time conc[/INDENT][INDENT=2]gen auc_`v' = r(auc)[/INDENT]
}exit
end
runby pk_id, by(id)
0 Response to Collecting PK values by id variable using statsby
Post a Comment