BookmarkSubscribeRSS Feed
jenim514
Pyrite | Level 9

@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;

1 REPLY 1
PGStats
Opal | Level 21

"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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 767 views
  • 0 likes
  • 2 in conversation