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
Lexis Diagram- Not able to make Parallelograms to show follow up of cohortDear Stata Users I am quite new to stata and using version 15.1 in mac. I have been trying to make L…
How to rename dummy variables based on category names?Hi, all. I have a data set with variable "town_id" indicating town id (such as 160, 155, 178, etc.)…
How can I covert Oaxaca-Decomposition coef. into an amount(dollar...)?I got the following results through oaxaca two-fold method. ---------------------------------------…
landmark analysis differences between time-periodsHello everyone, I have a cohort with 1 group (no comparison group). I created a landmark analysis …
variable name abbreviation in generate/replace sequenceThere seems to be some inconsistency about how to abbreviate variable names. I would like to abbrevi…
Subscribe to:
Post Comments (Atom)
0 Response to Matching data in a case control
Post a Comment