BookmarkSubscribeRSS Feed
Brander
Calcite | Level 5

Hi everyone,

 

I have two datasets of individuals, one of 1155 cases and one of 22000 potential controls. I would like to match the cases to the controls on the variable "age" (within a 1-2 year span), but I want each control to only occur once. Having matched all possible combinations, some have as few as 13 matches and some have as many as 2000. If possible, I would for each case to be matched to the same number of unique controls. The selection of controls, where there are many options, should be randomized.

 

proc sql; create table match as select
	a.case_id,a.case_age, b.match_id, b.match_age, ranuni(383467663) as rand
	from 	cases as a,
			controls as b
	where
	(b.match_age-1)<a.case_age<(b.match_age+1)
	order by a.case_id;
quit;

 

I've used randomly generated numbers to sort by and delete duplicates among the controls. But I then end up with as few as one control for some cases (and still almost 2000 for others), and seem to lose some cases as well, which I definitely don't want to do.

 

Any ideas?

 

Thanks in advance!

1 REPLY 1
Doc_Duke
Rhodochrosite | Level 12

Try this Google search

 

matching macro sas

 

Many others have addressed this problem over the years.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 679 views
  • 1 like
  • 2 in conversation