I have a simple one that I wrote a couple of years ago based on ideas in a paper by Craig Roberts and John R. Gerlach and the PSMatching macro presented at SAS Global Forum 2007 by Marcelo Coca Perraillon. http://www2.sas.com/proceedings/forum2007/185-2007.pdf It assumes that you have already calculated a single numeric score variable that will be used to match cases to controls. Here is the program header that describes what it can do. %macro psmatch /*---------------------------------------------------------------------- Propensity Score Matching - match treated cases to controls ----------------------------------------------------------------------*/ (treated= /* Input dataset of treated cases (REQ) */ ,control= /* Input dataset of controls (REQ) */ ,out= /* Output dataset of matched id numbers (DEF=MATCH) */ ,method= /* Matching method (NN RADIUS CALIPER) (DEF=NN) */ ,caliper= /* Pscore delta (used by CALIPER and RADIUS method)*/ ,id= /* Name of ID variable (DEF=ID) */ ,pscore= /* Name of Propensity Score variable (DEF=PSCORE) */ ,nmatch= /* Number of controls to match per subject (DEF=1) */ ,replacement= /* Select controls with replacement? (def=Y) */ ,seed1= /* Seed for randomizing treated case order */ ,seed2= /* Seed for randomizing control order */ ); /*---------------------------------------------------------------------- Propensity Score Matching Match treated cases to one or more controls. This does simple distance based on absolute difference between the Propensity Score of the case and the potential matched control. The propensity score variable must already be in the input datasets. Three methods of selecting the matches are available. Methods NN - Nearest neighbor. Find control with closest propensity score. CALIPER - Same as NN but only consider scores within +/- &CALIPER RADIUS - Match ALL controls within +/- &CALIPER Based on ideas in paper by Craig Roberts and John R. Gerlach and the PSMatching macro presented at SAS Global Forum 2007 by Marcelo Coca Perraillon. http://www2.sas.com/proceedings/forum2007/185-2007.pdf Assumptions: - TREATED and CONTROL input datasets use same variable names for ID and propensity score variables. - The propensity score variable must be numeric. - The ID values must be unique keys for their datasets. Calls to: parmv.sas varexist.sas Outputs: Dataset with list of matched cases and controls. The output dataset is not sorted. Unmatched treated cases are not included in the output. VAR Description -------- ------------------------------------------------------- IDT Treated case ID IDC Control case ID DISTANCE Distance between the propensity scores (absolute value) Usage Notes: - When using SAS Version 9.1 or higher will use a hash object. - Creates work datasets _TREATED and _CONTROL. - When NMATCH > 1 then also creates and deletes view _TREATV_. - When METHOD=RADIUS replacement parameter does not apply. Controls are selected within a treated case without replacement but are available for matching to other treated cases (with replacement). - Treated and Control datasets are randomly ordered so that when there are multiple controls of equal distance a random one will be selected. ----------------------------------------------------------------------- History: 02AUG2009 abernt Creation ----------------------------------------------------------------------*/
... View more