<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Propensity Score Matching Macro %GMATCH Question on 1:2 Match in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Propensity-Score-Matching-Macro-GMATCH-Question-on-1-2-Match/m-p/870208#M343725</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm conducting a propensity score match with the %GMATCH macro. There is a great content out there outlining sample code within a textbook with this macro that I have followed to ensure that my code is appropriate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pre-Match we have 199 patients in the intervention group (treatment) and 802 observations in the comparator group (control).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My 1:1 match was great, no issues. 180 patients matched to 180 patients. The code to call the %gmatch macro is below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%gmatch(
&amp;nbsp; data = out_ps_dm9,
&amp;nbsp; group = study_group,
&amp;nbsp; id = id,
&amp;nbsp; mvars = logit_ps_dm9,
&amp;nbsp; wts = 1,
&amp;nbsp; dist = 1,
&amp;nbsp; dmaxk = &amp;amp;stdcal,
&amp;nbsp; ncontls = 1,
&amp;nbsp; seedca = 25102007,
&amp;nbsp; seedco = 26102007,
&amp;nbsp; out = matchpairs_dm9,
&amp;nbsp; print = F
);

** Currently doing a 1 to 1 match, Match subjects on the logit of the propensity score. **;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;I'm struggling with the 1:2 match. When matching 1:2, the treatment group (intervention group) is being matched at a rate of 1:2, but the final dataset has 359 patients in intervention group and 359 patients in the comparator group. It is still only ~180 patients from the intervention group in the final dataset, but they are listed twice because they are associated with two pairs in the comparator group.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How do I analyze the dataset with 359:359 patients?&lt;/STRONG&gt; Using PROC PSMATCH and doing a 1:2 match, I had 180 patients matched to 360 patients in my final dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my code of doing the %GMATCH with 1:2 matching:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%gmatch(
  DATA = out_ps_dm9, /* Data: the name of the SAS data set containing the treated and untreated subjects.*/
  group = study_group, /* Group: the variable identifying treated/untreated subjects. */
  id = id, /* Id: the variable denoting subjects’ identification numbers. */
  mvars = logit_ps_dm9, /* Mvars: the list of variables on which one is matching.*/
  wts = 1, /* Wts: the list of non-negative weights corresponding to each matching variable.*/
  dist = 1,/* Dist: the type of distance to calculate [1 indicates weighted sum (over matching variables) of absolute case-control differences]*/
  dmaxk = &amp;amp;stdcal, /* Dmaxk: the maximum allowable difference in the matching difference between matched treated and untreated subjects.*/
  ncontls = 2, /* Ncontls: the number of untreated subjects to be matched to each treated subject.*/
  seedca = 25102007, /* Seedca: the random number seed for sorting the treated subjects prior to matching.*/
  seedco = 26102007, /* Seedco: the random number seed for sorting the untreated subjects prior to matching. */
  out = matchpairs_dm92, /* Out: the name of a SAS data set containing the matched sample.*/
  print = F /* Print: the flag indicating whether the matched data should be printed.*/
);
** Currently doing a 1 to 2 match, matching subjects on the logit of the propensity score. **;

DATA matchpairs_dm92;
  SET matchpairs_dm92;
  pair_id = _N_;
RUN;

PROC CONTENTS DATA = matchpairs_dm9 POSITION; RUN;

DATA control_match_dm92;
  SET matchpairs_dm92;
  control_id = __IDCO;
  logit_ps = __CO1;
  KEEP pair_id control_id logit_ps;
RUN;
/* Create a data set containing the matched comparator patients (untreated subjects) */

PROC CONTENTS DATA = control_match_dm92 POSITION; RUN;

DATA case_match_dm92;
  SET matchpairs_dm92;
  case_id = __IDCA;
  logit_ps = __CA1;
  KEEP pair_id case_id logit_ps;
RUN;
/* Create a data set containing the matched intervention patients (treated subjects) */

PROC CONTENTS DATA = case_match_dm92 POSITION; RUN;

PROC SORT DATA=control_match_dm92; BY control_id; RUN;
PROC SORT DATA=case_match_dm92; BY case_id; RUN;

DATA exposed_dm92;
	SET out_ps_dm9;
	IF study_group = 1;
	case_id = id;
RUN;

PROC CONTENTS DATA = exposed_dm92 POSITION; RUN;

DATA control_dm92;
	SET out_ps_dm9;
	IF study_group = 0;
	control_id = id;
RUN;

PROC CONTENTS DATA = control_dm92 POSITION; RUN;

PROC SORT DATA=exposed_dm92; BY case_id; RUN;
PROC SORT DATA=control_dm92; BY control_id; RUN;

DATA control_match_dm92;
  MERGE control_match_dm92 (IN=f1) control_dm92 (IN=f2);
  BY control_id;
  IF f1 and f2;
RUN;

PROC CONTENTS DATA = control_match_dm92 POSITION; RUN;

DATA case_match_dm92;
  MERGE case_match_dm92 (IN=f1) exposed_dm92 (IN=f2);
  BY case_id;
  IF f1 and f2;
RUN;

PROC CONTENTS DATA = case_match_dm92 POSITION; RUN;

DATA long_dm92;
  SET control_match_dm92 case_match_dm92;
  prop_score = exp(logit_ps) / (exp(logit_ps) + 1);
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you! I want to ensure that I am appropriately assessing both my groups with a 1:2 match and a 1:3 match.&lt;/P&gt;&lt;P&gt;Tyler&lt;/P&gt;</description>
    <pubDate>Mon, 17 Apr 2023 17:39:07 GMT</pubDate>
    <dc:creator>twagner</dc:creator>
    <dc:date>2023-04-17T17:39:07Z</dc:date>
    <item>
      <title>Propensity Score Matching Macro %GMATCH Question on 1:2 Match</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Propensity-Score-Matching-Macro-GMATCH-Question-on-1-2-Match/m-p/870208#M343725</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm conducting a propensity score match with the %GMATCH macro. There is a great content out there outlining sample code within a textbook with this macro that I have followed to ensure that my code is appropriate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pre-Match we have 199 patients in the intervention group (treatment) and 802 observations in the comparator group (control).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My 1:1 match was great, no issues. 180 patients matched to 180 patients. The code to call the %gmatch macro is below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%gmatch(
&amp;nbsp; data = out_ps_dm9,
&amp;nbsp; group = study_group,
&amp;nbsp; id = id,
&amp;nbsp; mvars = logit_ps_dm9,
&amp;nbsp; wts = 1,
&amp;nbsp; dist = 1,
&amp;nbsp; dmaxk = &amp;amp;stdcal,
&amp;nbsp; ncontls = 1,
&amp;nbsp; seedca = 25102007,
&amp;nbsp; seedco = 26102007,
&amp;nbsp; out = matchpairs_dm9,
&amp;nbsp; print = F
);

** Currently doing a 1 to 1 match, Match subjects on the logit of the propensity score. **;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;I'm struggling with the 1:2 match. When matching 1:2, the treatment group (intervention group) is being matched at a rate of 1:2, but the final dataset has 359 patients in intervention group and 359 patients in the comparator group. It is still only ~180 patients from the intervention group in the final dataset, but they are listed twice because they are associated with two pairs in the comparator group.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How do I analyze the dataset with 359:359 patients?&lt;/STRONG&gt; Using PROC PSMATCH and doing a 1:2 match, I had 180 patients matched to 360 patients in my final dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my code of doing the %GMATCH with 1:2 matching:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%gmatch(
  DATA = out_ps_dm9, /* Data: the name of the SAS data set containing the treated and untreated subjects.*/
  group = study_group, /* Group: the variable identifying treated/untreated subjects. */
  id = id, /* Id: the variable denoting subjects’ identification numbers. */
  mvars = logit_ps_dm9, /* Mvars: the list of variables on which one is matching.*/
  wts = 1, /* Wts: the list of non-negative weights corresponding to each matching variable.*/
  dist = 1,/* Dist: the type of distance to calculate [1 indicates weighted sum (over matching variables) of absolute case-control differences]*/
  dmaxk = &amp;amp;stdcal, /* Dmaxk: the maximum allowable difference in the matching difference between matched treated and untreated subjects.*/
  ncontls = 2, /* Ncontls: the number of untreated subjects to be matched to each treated subject.*/
  seedca = 25102007, /* Seedca: the random number seed for sorting the treated subjects prior to matching.*/
  seedco = 26102007, /* Seedco: the random number seed for sorting the untreated subjects prior to matching. */
  out = matchpairs_dm92, /* Out: the name of a SAS data set containing the matched sample.*/
  print = F /* Print: the flag indicating whether the matched data should be printed.*/
);
** Currently doing a 1 to 2 match, matching subjects on the logit of the propensity score. **;

DATA matchpairs_dm92;
  SET matchpairs_dm92;
  pair_id = _N_;
RUN;

PROC CONTENTS DATA = matchpairs_dm9 POSITION; RUN;

DATA control_match_dm92;
  SET matchpairs_dm92;
  control_id = __IDCO;
  logit_ps = __CO1;
  KEEP pair_id control_id logit_ps;
RUN;
/* Create a data set containing the matched comparator patients (untreated subjects) */

PROC CONTENTS DATA = control_match_dm92 POSITION; RUN;

DATA case_match_dm92;
  SET matchpairs_dm92;
  case_id = __IDCA;
  logit_ps = __CA1;
  KEEP pair_id case_id logit_ps;
RUN;
/* Create a data set containing the matched intervention patients (treated subjects) */

PROC CONTENTS DATA = case_match_dm92 POSITION; RUN;

PROC SORT DATA=control_match_dm92; BY control_id; RUN;
PROC SORT DATA=case_match_dm92; BY case_id; RUN;

DATA exposed_dm92;
	SET out_ps_dm9;
	IF study_group = 1;
	case_id = id;
RUN;

PROC CONTENTS DATA = exposed_dm92 POSITION; RUN;

DATA control_dm92;
	SET out_ps_dm9;
	IF study_group = 0;
	control_id = id;
RUN;

PROC CONTENTS DATA = control_dm92 POSITION; RUN;

PROC SORT DATA=exposed_dm92; BY case_id; RUN;
PROC SORT DATA=control_dm92; BY control_id; RUN;

DATA control_match_dm92;
  MERGE control_match_dm92 (IN=f1) control_dm92 (IN=f2);
  BY control_id;
  IF f1 and f2;
RUN;

PROC CONTENTS DATA = control_match_dm92 POSITION; RUN;

DATA case_match_dm92;
  MERGE case_match_dm92 (IN=f1) exposed_dm92 (IN=f2);
  BY case_id;
  IF f1 and f2;
RUN;

PROC CONTENTS DATA = case_match_dm92 POSITION; RUN;

DATA long_dm92;
  SET control_match_dm92 case_match_dm92;
  prop_score = exp(logit_ps) / (exp(logit_ps) + 1);
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you! I want to ensure that I am appropriately assessing both my groups with a 1:2 match and a 1:3 match.&lt;/P&gt;&lt;P&gt;Tyler&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2023 17:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Propensity-Score-Matching-Macro-GMATCH-Question-on-1-2-Match/m-p/870208#M343725</guid>
      <dc:creator>twagner</dc:creator>
      <dc:date>2023-04-17T17:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Propensity Score Matching Macro %GMATCH Question on 1:2 Match</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Propensity-Score-Matching-Macro-GMATCH-Question-on-1-2-Match/m-p/870440#M343797</link>
      <description>&lt;P&gt;For analysis, it's essentially a problem of 1) non-independence of observations, and 2) weighting of the multiple control groups in the analysis.&amp;nbsp; Below is assuming all of your matched cases from both control groups (combined) are unique observations--not duplicated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The simplest solution, which is probably reasonable acceptable to most people, is likely to simply analyze the two sets of matched pairs separately, and present it as a "replication".&amp;nbsp; If the results are the same for both matched groups, then you can say the same result is achieved with propensity score matching even with an independent control group.&amp;nbsp; If the results are different, it would merit investigation as to whether the difference is due to detectable differences in the matched characteristics of the two control groups (or their difference-in-difference with the study group).&amp;nbsp; Such differences could emerge, and be observed, for example, if a first iteration of the propensity match is a "closer match" than the second iteration of propensity match.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Partial solutions, which I'm sure would be unsatisfactory to the scientific community (and to me), would be to:&amp;nbsp; a) code the two control groups (e.g. 1 vs. 0) into a variable and enter it as a covariate in a model using all the data, including the double study observations.&amp;nbsp; This would not solve the problem of non-independence, but would more-or-less ensure both control groups are weighted equally and fairly, removing any bias that snuck in from one propensity match iteration to the next.&amp;nbsp; b) Pool or average your responses from the two control groups into a single observation, as to be matched with a single observation of the study group.&amp;nbsp; This resolves the issue of non-independence, and partially ensures the control observations are weighted relatively equally; however, it definitely distorts the underlying true variance of observations in the control groups (which wouldn't necessarily be a problem if you had, say, 20 matched control groups, and could use their observed variance).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A slightly more complicated solution would be to construct a multilevel model.&amp;nbsp; There, you can enter the study group ID as the identifier for level-2, and the control group ID's as independent observations for level-1.&amp;nbsp; Since you would presumably be predicting level-2 outcomes from level-1 predictors, you could use a simple fixed-effects model (which is relatively simple, nice).&amp;nbsp; This should take care of both your issues of non-independence and comparative weighting of the multiple control groups in a single analysis.&amp;nbsp; Also, as in a) above, you could again code and enter propensity match iteration as a covariate in the model.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 20:56:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Propensity-Score-Matching-Macro-GMATCH-Question-on-1-2-Match/m-p/870440#M343797</guid>
      <dc:creator>awesome_opossum</dc:creator>
      <dc:date>2023-04-18T20:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: Propensity Score Matching Macro %GMATCH Question on 1:2 Match</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Propensity-Score-Matching-Macro-GMATCH-Question-on-1-2-Match/m-p/882492#M348648</link>
      <description>&lt;P&gt;Hi, I try to do the match 1:1 using exact codes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting stuck with these. Can you help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%include 'gmatch.sas';&lt;/P&gt;&lt;P&gt;%gmatch(&lt;BR /&gt;data = out_ps,&lt;BR /&gt;group = old,&lt;BR /&gt;id = id,&lt;BR /&gt;mvars = logit_ps,&lt;BR /&gt;wts = 1,&lt;BR /&gt;dist = 1,&lt;BR /&gt;dmaxk = &amp;amp;stdcal,&lt;BR /&gt;ncontls = 1,&lt;BR /&gt;seedca = 25102007,&lt;BR /&gt;seedco = 26102007,&lt;BR /&gt;out = matchpairs,&lt;BR /&gt;print = F&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="duongngoclanchi_0-1687802266595.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85400i570E7F000FD7A579/image-size/medium?v=v2&amp;amp;px=400" role="button" title="duongngoclanchi_0-1687802266595.png" alt="duongngoclanchi_0-1687802266595.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 17:57:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Propensity-Score-Matching-Macro-GMATCH-Question-on-1-2-Match/m-p/882492#M348648</guid>
      <dc:creator>duongngoclanchi</dc:creator>
      <dc:date>2023-06-26T17:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Propensity Score Matching Macro %GMATCH Question on 1:2 Match</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Propensity-Score-Matching-Macro-GMATCH-Question-on-1-2-Match/m-p/882495#M348649</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am doing the match 1:1 but I have an issue with this part. Can you help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%include 'gmatch.sas';&lt;/P&gt;&lt;P&gt;%gmatch(&lt;BR /&gt;data = out_ps,&lt;BR /&gt;group = old,&lt;BR /&gt;id = id,&lt;BR /&gt;mvars = logit_ps,&lt;BR /&gt;wts = 1,&lt;BR /&gt;dist = 1,&lt;BR /&gt;dmaxk = &amp;amp;stdcal,&lt;BR /&gt;ncontls = 1,&lt;BR /&gt;seedca = 25102007,&lt;BR /&gt;seedco = 26102007,&lt;BR /&gt;out = matchpairs,&lt;BR /&gt;print = F&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="duongngoclanchi_0-1687802333380.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85401iB01C66C23F88AF0C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="duongngoclanchi_0-1687802333380.png" alt="duongngoclanchi_0-1687802333380.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 17:59:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Propensity-Score-Matching-Macro-GMATCH-Question-on-1-2-Match/m-p/882495#M348649</guid>
      <dc:creator>duongngoclanchi</dc:creator>
      <dc:date>2023-06-26T17:59:13Z</dc:date>
    </item>
  </channel>
</rss>

