I am working with a dataset that has 4 genotypes (gene1, gene2, gene3,
gene4) and each genotype may have discordant values for a particular
study subject. i.e.
The statalist (ie Nick) had previously helped me identify genotypes that
are discordant for one gene for one individual. Now I would like to
write only those discordant genotypes out to a .txt file so that I can
take it back to the lab. i.e.
study_id gene genotype
a-1 gene1 ww
a-1 gene1 vv
I can do this using a temporary file (see below), but I suspect that
using a temporary file is not the most appropriate/elegent way to do
this. I'd be most appreciate of anyone's education efforts on my
behalf. If you go to AACR or ASH, I'll buy you a beer/coffee there. :)
Thanks in advance.
local genotypes "gene1 gene2 gene3 gene4"
file open discordant using discordant.txt, write replace
file write discordant
foreach gene of local genotypes {
preserve
tempfile data
save "`data'"
keep if disc_`gene' == 1
file write discordant "Study ID" _tab "Gene" _tab "Genotype" _n
local N = _N
sort study_id `gene'
forvalues i = 1/`N' {
file write discordant (study_id[`i']) _tab "`gene'" _tab
(`gene'[`i']) _n
}
restore
}
file close discordant
Richard
--
Richard Aplenc, MD, MSCE
Pediatric Oncology/Stem Cell Transplant
Children's Hospital of Philadelphia
Center for Clinical Epidemiology and Biostatistics
University of Pennsylvania
215-573-0259 (lab)
215-590-4183 (fax) [email protected]
CONFIDENTIALITY
This email and any attachments may contain confidential information
belonging to the sender that is legally privileged. Any unauthorized
disclosure, copying, distribution, or the unauthorized taking of action
based on the contents of this email is strictly prohibited. If you are
not the named recipient, or have otherwise received this communication
in error, please delete it from you inbox, notify the sender
immediately, and do not disclose its contents to any other person, use
them for any purpose, or store or copy them in any medium.