<?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 Re: PROC PSMATCH -Manual SMD recalculation mismatch in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-PSMATCH-Manual-SMD-recalculation-mismatch/m-p/953968#M372630</link>
    <description>&lt;P&gt;Yeah I tried that but no luck and this is what nlargestwgt does. removing it has no impact. It seems like&amp;nbsp; i need a&amp;nbsp;&lt;SPAN data-teams="true"&gt;corrected formula for the variance of the weighted probabilities&lt;/SPAN&gt;&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="smackerz1988_0-1734521488943.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103137i81D3883D3E92FC77/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smackerz1988_0-1734521488943.png" alt="smackerz1988_0-1734521488943.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Dec 2024 11:32:27 GMT</pubDate>
    <dc:creator>smackerz1988</dc:creator>
    <dc:date>2024-12-18T11:32:27Z</dc:date>
    <item>
      <title>PROC PSMATCH -Manual SMD recalculation mismatch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-PSMATCH-Manual-SMD-recalculation-mismatch/m-p/953848#M372602</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I’ve been manually recalculating the &lt;STRONG&gt;Standardized Mean Difference (SMD)&lt;/STRONG&gt; for categorical variables, but the values I calculate differ from those provided by &lt;CODE&gt;PROC PSMATCH&lt;/CODE&gt;. Below is my approach and code for one specific variable, &lt;CODE&gt;PCDK46&lt;/CODE&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;Step 1: My PROC PSMATCH Code&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;This code generates the propensity score weights (&lt;CODE&gt;_ATTWgt_&lt;/CODE&gt;) and outputs the standardized differences table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics on;
proc psmatch data=ac_padsl region=allobs; 
   class PSTUDYID PECOGBL PCDK46 PHER2 PRACE PSTAGE PSTYESYN PSTNOYN PSTUNKYN PRASIAYN PRAFRYN PRWHTYN PROTHYN PRUNKYN;  
   psmodel PSTUDYID (Treated='Study') = PAGE PECOGBL PCDK46 PLINES PRACE PSTAGE PHER2;
   psweight weight=attwgt nlargestwgt=6; 
   assess lps var=(PAGE PECOGBL PCDK46 PLINES PSTYESYN PSTNOYN PSTUNKYN PRASIAYN PRAFRYN PRWHTYN PROTHYN PRUNKYN PHER2) 
          / varinfo plots=(barchart boxplot(display=(lps PAGE)) wgtcloud);  
   id PAGE PLINES PECOGBL PCDK46 PHER2;  
   output out(obs=all)=ac_OutEx1 weight=_ATTWgt_;
   ods output StdDiff=ac_myStdDiff; 
run;
ods graphics off;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;H3&gt;&lt;STRONG&gt;Step 2: Manual Calculation of Weighted Prevalence and SMD&lt;/STRONG&gt;&lt;/H3&gt;
&lt;H4&gt;&lt;STRONG&gt;Weighted Prevalence for &lt;CODE&gt;PCDK46&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/H4&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Treatment group prevalence */
proc freq data=ac_OutEx1 noprint;
    where pstudyid = "Study";
    tables PCDK46 / nocol norow out=treatment_output (rename=(percent=prevalence_treatment));
    weight _ATTWgt_;
run;

/* Control group prevalence */
proc freq data=ac_OutEx1 noprint;
    where pstudyid = "Flatiron";
    tables PCDK46 / nocol norow out=control_output (rename=(percent=prevalence_control));
    weight _ATTWgt_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Merge Treatment and Control Data to Calculate SMD&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data combined_output;
    merge treatment_output (keep=PCDK46 prevalence_treatment)
          control_output (keep=PCDK46 prevalence_control);
    by PCDK46;
run;

/* Calculate SMD */
data smd_result_PCDK46;
    set combined_output end=last;

    /* Convert prevalence to proportions */
    if PCDK46 = "Y" then do;
        p_treatment = prevalence_treatment / 100;
        p_control = prevalence_control / 100;

        /* SMD Formula */
        smd = (p_treatment - p_control) / sqrt(
                ((p_treatment * (1 - p_treatment)) + (p_control * (1 - p_control))) / 2
             );
        
    end;

    variable = "PCDK46";
    keep variable smd;
    if last;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;From this i get&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;0.063704264&lt;/STRONG&gt; for PCDK46 but in PROC PSMATCH i get&amp;nbsp;&lt;STRONG&gt;0.05313.&amp;nbsp;&lt;/STRONG&gt; Can anyone provide any insights?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2024 15:28:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-PSMATCH-Manual-SMD-recalculation-mismatch/m-p/953848#M372602</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2024-12-17T15:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: PROC PSMATCH -Manual SMD recalculation mismatch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-PSMATCH-Manual-SMD-recalculation-mismatch/m-p/953924#M372616</link>
      <description>The variable PCDK46 has exactly 2 levels and no missing values?</description>
      <pubDate>Tue, 17 Dec 2024 21:06:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-PSMATCH-Manual-SMD-recalculation-mismatch/m-p/953924#M372616</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2024-12-17T21:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: PROC PSMATCH -Manual SMD recalculation mismatch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-PSMATCH-Manual-SMD-recalculation-mismatch/m-p/953937#M372618</link>
      <description>Correct</description>
      <pubDate>Wed, 18 Dec 2024 00:55:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-PSMATCH-Manual-SMD-recalculation-mismatch/m-p/953937#M372618</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2024-12-18T00:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: PROC PSMATCH -Manual SMD recalculation mismatch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-PSMATCH-Manual-SMD-recalculation-mismatch/m-p/953940#M372620</link>
      <description>Only thing I can think is to try the PSMATCH with PCDK46 as the only explanatory variable in the PSMODEL statement and seeing if the associated SMD (from the StdDiff table output) is the same as what you're currently getting.  I also don't know offhand what the 'nlargestwgt' argument is doing and whether that's affecting things.</description>
      <pubDate>Wed, 18 Dec 2024 01:33:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-PSMATCH-Manual-SMD-recalculation-mismatch/m-p/953940#M372620</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2024-12-18T01:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: PROC PSMATCH -Manual SMD recalculation mismatch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-PSMATCH-Manual-SMD-recalculation-mismatch/m-p/953968#M372630</link>
      <description>&lt;P&gt;Yeah I tried that but no luck and this is what nlargestwgt does. removing it has no impact. It seems like&amp;nbsp; i need a&amp;nbsp;&lt;SPAN data-teams="true"&gt;corrected formula for the variance of the weighted probabilities&lt;/SPAN&gt;&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="smackerz1988_0-1734521488943.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103137i81D3883D3E92FC77/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smackerz1988_0-1734521488943.png" alt="smackerz1988_0-1734521488943.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 11:32:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-PSMATCH-Manual-SMD-recalculation-mismatch/m-p/953968#M372630</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2024-12-18T11:32:27Z</dc:date>
    </item>
  </channel>
</rss>

