DATA Step, Macro, Functions and more

matching case-control

Reply
Frequent Contributor
Posts: 142

matching case-control

[ Edited ]

@PGStats

Hi!  I recently used some syntax you created for a match sase- control table for a question posted in 2012:

https://communities.sas.com/t5/forums/replypage/board-id/programming/message-id/22601

 

This seemed to work but I need some help troubleshooting.

 

1.  The control id (ne_ssn) is duplicating and being used more than once.  I want to be matched only once to a case (e_ssn).

2.  Some cases are matched to over 200+ controls.  I want to limit it to 5 matches.

3. I seems some of my cases are not appearing at all in my final table (e.g. 620K cases but final table only matched 600K cases).  Does this mean there are no matches at all for the missing?

 

Any help is much apprecited!!

 

Here is my syntax:


proc sort data=tmp;
by service_entry_date study rand_num;
run;
* 'study' variable is 1=case 0=control;

proc rank data=tmp out=tempR;
by service_entry_date study;
var rand_num;
run;
*assign random order;


proc sql;
create table exp2.match as
select a.ssn as e_ssn, a.service_branch as e_service_branch, a.sex as e_sex, a.service_entry_date as e_service_entry_date, a.study,
b.ssn as ne_ssn, b.service_branch as ne_service_branch, b.sex as ne_sex, b.service_entry_date as ne_service_entry_date, b.study
from tempr as a inner join tempr as b
     on( a.service_entry_date between b.service_entry_date and b.service_entry_date_low) and a.service_branch=b.service_branch and
a.sex=b.sex and a.rand_num=ceil(b.rand_num/5)
where a.study and not b.study;
drop table tmp, tmpR;
quit;

Respected Advisor
Posts: 4,930

Re: matching case-control

"This seemed to work" but it clearly doesn't. Therefore, your problem must be different from the one posted in 2012.

 

Please post this question as a new topic with your description of the case-control matching rules and some test data.

PG
Ask a Question
Discussion stats
  • 1 reply
  • 236 views
  • 0 likes
  • 2 in conversation