Hello there,
I am trying to match data for a case control study on a positive cancer diagnosis on both location and age with a matching negative diagnosis with the same location and age. I also need to merge them into one dataset to show that each of the 50 positive cases was randomly selected a comparison from the pool of comparisons with not more than one match for the 50 positive. I have put my code below. The issue I am having is that when I join them together I end up with a very large number of matches and not the 50 as expected. I also dont know how to merge into one dataset to produce a clear table output. I have used some of @ClydeSchechter code previously but am very confused.
Any help is much appreciated!
Code:
preserve
keep if abb == 1
rename * *_case
rename id_case caseID
rename abb_case cancer
rename abbage_case age
rename abblocation_case location
tempfile cases
save cases
restore
keep if abc==2
rename * *_comparison
rename id_comparison ID
rename abc_comparison cancer
rename abcage_comparison age
rename abclocation_comparison location
tempfile comparison
save comparison
use comparison
set seed 12345
gen rand = runiform()
sort rand
drop rand
save comparison, replace
use cases
joinby age location using comparison
Related Posts with Matching data in a case control
ConditionalsHI how can I change this list ??? converting those texts to missing? x: sales in $ x | Freq. Perc…
Download and unzip file with StataHi, I was wondering if it is possible to download a *.zip file from a website, unzip the *.csv file…
Record linkage with quantitative variablesI have two datasets describing the same 80 schools. Some variables are similar -- for example, both…
How to clear preserve? "Already preserve error"Hi, I have been running a piece of code through various universe of assets and I am getting the "al…
Arellano-Bond in Stata: xtabond, xtabond2, or xtdpdgmm if I'm including an interaction? And can I enter differenced focal variables?Hi, I'm trying to run a dynamic panel model on a panel dataset in Stata 14.1. I have a couple questi…
Subscribe to:
Post Comments (Atom)
0 Response to Matching data in a case control
Post a Comment