BookmarkSubscribeRSS Feed
kjmathes03
Fluorite | Level 6

Hello,

 

I have a dataset with 87 cases and 1000's of controls. I want to match 2:1 with out replacement for the controls. I want to match on year of procedure (+/- 2 years), diagnosis (which can have 6 different values) and sex. I have searched through many papers online which did not remove duplicate controls. 

kjmathes03_0-1647023595230.png

 kjmathes03_1-1647023642058.png

As well as the above paper which also did not remove duplicates.

 

I am trying the following code

DATA cases controls;
SET cohort3;
IF fvii_inclusion = 1 THEN OUTPUT cases;
ELSE OUTPUT controls;
RUN;
data control2;
set controls;
time_low=timet-2;
time_high=timet+2;
run;
proc sql;
create table controls_id
as select
one.uniqueid as case_id,
two.uniqueid as control_id,
one.timet as case_time,
two.timet as control_time ,
one.proc as case_proc,
two.proc as control_proc,
one.sex as case_sex,
two.sex as control_sex,


from cases one, control2 two
where ((one.timet between two.time_low and two.time_high) and (one.sex=two.sex) and one.proc=two.proc) ;

 

I also reviewed the suggestions on hash tags for a similar problem posted but it changed nothing.

 

HELP much appreciated!

1 REPLY 1
benjamin_2018
Fluorite | Level 6

If you want to remove duplicate controls then could you try adding the distinct option in the select statement in your proc sql code? 

Then, if you want 2 controls per case, you could try proc surveyselect, something like:

 

proc surveyselect data=controls_id method=srs sampsize=2;

strata case_id;

run;

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 715 views
  • 1 like
  • 2 in conversation