|
Dear list
In a sample of 2000 individuals we would like to compare 41 cases with 41 matched controls (matching according to age, gender, socioeconomic status). Is there a way to draw this control group automatically? So far we tried with a macro from Raynald's webpage (findRandomPairsOfCasesWithSameCharacteristics.txt) which however also draws a random sample from the cases. Thanks very much Sakari Lemola ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
Hi Sakari,
I believe the code below is what you want, but please check it thoroughly. There may, depending on how refined your strata are, not always be matched case control pairs. Cheers!! Albert-Jan * seed, needed for reproducability. set rng=mt mtindex= 20090120. * sample data. input program. loop #i=1 to 2000. compute ses = trunc(rv.uniform(0, 5)). compute age = trunc(rv.uniform(18, 45)). compute sex = trunc(rv.uniform(1, 2.9)). compute blah = rv.normal(1, 100). compute bloh = rnd(rv.normal(1, 52)). compute casecontr = trunc(rv.uniform(0,1.9)). end case. end loop. end file. end input program. value labels casecontr 0 'control' 1 'case'. variable label blah 'mysterious outcome var #1' / bloh 'mysterious outcome var #2'. * actual code. compute random = rv.uniform(0,1). sort cases by casecontr sex age ses random. aggr out = * / presorted / break = casecontr sex age ses / blah = first (blah) / bloh = first (bloh). formats all (f5). sort cases by sex age ses. casestovars / id = sex age ses / index = casecontr. begin program. import spss spss.Submit("sample 41 from %s." % spss.GetCaseCount()) end program. exe. ----- Original Message ---- From: Sakari Lemola <[hidden email]> To: [hidden email] Sent: Tuesday, January 20, 2009 9:57:47 AM Subject: Sampling question: How to draw a matched control group Dear list In a sample of 2000 individuals we would like to compare 41 cases with 41 matched controls (matching according to age, gender, socioeconomic status). Is there a way to draw this control group automatically? So far we tried with a macro from Raynald's webpage (findRandomPairsOfCasesWithSameCharacteristics.txt) which however also draws a random sample from the cases. Thanks very much Sakari Lemola ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
In reply to this post by Sakari Lemola
Are you trying to draw 41 cases at random and then matching them with 41 other cases in the same sample or do you have the conventional setup of a set of cases that you want to match with a dataset of controls? If the latter, the CASECTRL extension command downloadable from SPSS Developer Central (www.spss.com/devcentral) can do this. It requires at least SPSS version 16 and the Python programmability plug-in.
HTH, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Sakari Lemola Sent: Tuesday, January 20, 2009 1:58 AM To: [hidden email] Subject: [SPSSX-L] Sampling question: How to draw a matched control group Dear list In a sample of 2000 individuals we would like to compare 41 cases with 41 matched controls (matching according to age, gender, socioeconomic status). Is there a way to draw this control group automatically? So far we tried with a macro from Raynald's webpage (findRandomPairsOfCasesWithSameCharacteristics.txt) which however also draws a random sample from the cases. Thanks very much Sakari Lemola ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
Dear Jon
It is the second option (conventional setup of a set of cases that we want to match with a dataset of controls). I will then have to get the CASECTRL extension and Python. Thanks for your comments. Sakari Am 20.1.2009 15:42 Uhr schrieb "Peck, Jon" unter <[hidden email]>: > Are you trying to draw 41 cases at random and then matching them with 41 other > cases in the same sample or do you have the conventional setup of a set of > cases that you want to match with a dataset of controls? If the latter, the > CASECTRL extension command downloadable from SPSS Developer Central > (www.spss.com/devcentral) can do this. It requires at least SPSS version 16 > and the Python programmability plug-in. > > HTH, > Jon Peck > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Sakari Lemola > Sent: Tuesday, January 20, 2009 1:58 AM > To: [hidden email] > Subject: [SPSSX-L] Sampling question: How to draw a matched control group > > Dear list > > In a sample of 2000 individuals we would like to compare 41 cases with 41 > matched controls (matching according to age, gender, socioeconomic status). > Is there a way to draw this control group automatically? > > So far we tried with a macro from Raynald's webpage > (findRandomPairsOfCasesWithSameCharacteristics.txt) which however also draws > a random sample from the cases. > > Thanks very much > > Sakari Lemola > > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
