LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2002, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 26 Feb 2002 16:48:57 -0500
Reply-To:     Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject:      Re: Version of Case Control Program
Comments: To: "JGerstle@SW.UA.EDU" <JGerstle@SW.UA.EDU>
Content-Type: text/plain; charset="iso-8859-1"

John,

Here is example sampling code. In my case two males do not have correspondent females. They are in the file PROB. The random matches are in file W. The example is curious because it is one of the few examples that I know of where one wants to do a one-to-one merge within by group legitimately.

The message

NOTE: MERGE statement has more than one data set with repeats of BY values.

is most likely and has been accounted for in the code.

data males ; do id = 1 to 20 ; agegrp = ceil ( 10 * ranuni ( 67493 ) ) ; salgrp = ceil ( 10 * ranuni ( 67493 ) ) ; output ; end ; run ;

data females ; do id = 100 to 299 ; agegrp = ceil ( 10 * ranuni ( 617493 ) ) ; salgrp = ceil ( 10 * ranuni ( 617493 ) ) ; output ; end ; run ;

data females ; set females ; random = ranuni ( 961743 ) ; run ;

proc sort data = males ; by agegrp salgrp ; run ;

proc sort data = females ; by agegrp salgrp random ; run ;

data w prob ; w = 0 ; f = 0 ; merge males ( in = w ) females ( in = f rename = id = fid ) ; by agegrp salgrp ; if w and f then output w ; else if w then output prob ; run ;

IanWhitlock@westat.com

-----Original Message----- From: John Gerstle [mailto:JGerstle@SW.UA.EDU] Sent: Tuesday, February 26, 2002 2:48 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Version of Case Control Program

SAS-Lers, I'm looking for some sample Case Control code. Presently, I have a dataset where I would like to match the 20 males with 20 females that match them along some parameters out of a total of 200 females. In other words, I would like to run some simple analyses based on gender, but only have 20 males versus 200 females. And let's say, that the parameters I would like to use are age (in five year increments) and income level (in $20K increments). So for every male, there is some subset of females that match in terms of age level and income level, and I would like to randomly select one of these females to 'pair' with the males. In this way, the two genders will be matched on age and income. I have been successful in manually creating matches (printing out the data, highlighting matches, hard coding ids to pull, etc...). But I would like to have something that would generalize over to a larger dataset with many more levels (say, 100 males and 2000 females). Does anyone have something that would do this? (I haven't checked SCONSIG or the SAS site yet...thought I'd question the List first in case others out there might need something similar.)

Thanks, John

John Gerstle, M.S. Program Analyst, Sr. Applied Gerontology Program University of Alabama


Back to: Top of message | Previous page | Main SAS-L page