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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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