<?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: SAS codes for bootstrapping for propensity score matched sample in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556569#M155033</link>
    <description>Thanks Reeza! Can you suggest a way to resolve the error on bootstrapping in the final step on regression?</description>
    <pubDate>Mon, 06 May 2019 20:29:38 GMT</pubDate>
    <dc:creator>schatterjee</dc:creator>
    <dc:date>2019-05-06T20:29:38Z</dc:date>
    <item>
      <title>SAS codes for bootstrapping for propensity score matched sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556563#M155031</link>
      <description>&lt;P&gt;Hello members,&lt;/P&gt;&lt;P&gt;I am trying to implement bootstrapping for generating propensity scores, perform PS matching (GREEDY 5→1 algorithm) and then obtain bootstrapped estimates from the final Cox regression. The final step is not executed and I am receiving the following error message:&lt;/P&gt;&lt;P&gt;"ERROR: Data set PERM.BOOTSAMPLEPSMATCH1 is not sorted in ascending sequence. The current BY group has Sample Replicate Number = 98 and the next BY group has Sample Replicate Number = 3."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see my editor below. Your help on this will be highly appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let rep = 100;

proc surveyselect data= cohort out=BOOTSAMPLE

     seed = 1347 method = urs

      samprate = 1 outhits rep = &amp;amp;rep;

run;

PROC LOGISTIC DATA=BOOTSAMPLE DESCENDING;
BY REPLICATE;

CLASS EXPOSURE AGE SEX CATVAR1 CATVAR2 CATVARN /PARAM=REF REF=FIRST;

MODEL NON_SEL = CATVAR1 CATVAR2 CATVARN CONTVAR1;

OUTPUT OUT= BOOTSAMPLEPS(DROP=_LEVEL_) PRED=PROB XBETA=LOGIT;
RUN;

/*============================================================*/
/*PS MATCHING*/
/*============================================================*/

%MACRO GREEDMTCH (Lib=, Dataset=, depend=, matches= );

%macro sortcc;

proc sort data = tctrl out = &amp;amp;lib..scontrol;
  by prob randnum;
run;

proc sort data = tcases out = &amp;amp;lib..scase;
   by prob ;
run;

%mend sortcc;

%macro initcc(digits);

data tcases(drop=cprob)
     tctrl(drop=aprob);
   set &amp;amp;lib..&amp;amp;dataset.;
   if &amp;amp;depend. = 0 then do;
     cprob = round(prob,&amp;amp;digits.);
     cmatch = 0;
     randnum = ranuni(1234567);
     output tctrl;
   end;
   else if &amp;amp;depend. = 1 then do;
      cmatch = 0;
      aprob = round(prob,&amp;amp;digits.);
      output tcases;
   end;
run;

%sortcc;
%mend initcc;

%macro match(matched,digits);

data &amp;amp;lib..&amp;amp;matched.(drop = cmatch randnum aprob cprob start oldi
             curctr1 matched);
    set &amp;amp;lib..scase;
    curob + 1;
    matchto = curob;
    if curob = 1 then do;
       start = 1;
       oldi  = 1;
    end;
    do i = start to n;
        set &amp;amp;lib..scontrol point = i nobs = n;
        if i &amp;gt; n then goto startovr;
        if _error_ = 1 then abort;
        curctr1 = i;
           if aprob = cprob then do;
              cmatch = 1;
              output &amp;amp;lib..&amp;amp;matched.;
              matched = curctr1;
              goto found;
           end;
           else if cprob &amp;gt; aprob then
                goto nextcase;
       startovr:
         if i &amp;gt; n then goto nextcase;
   end;
   nextcase:
       if cmatch = 0 then start = oldi;
   found:
       if cmatch = 1 then do;
          oldi  = matched + 1;
          start = matched + 1;
          set &amp;amp;lib..scase point = curob;
          output &amp;amp;lib..&amp;amp;matched.;
       end;
  retain oldi start;
  if _Error_=1 then _Error_=0;
run;

proc sort data = &amp;amp;lib..scase out = sumcase;
   by ID;
run;

proc sort data = &amp;amp;lib..scontrol out = sumcontrol;
   by ID;
run;

proc sort data = &amp;amp;lib..&amp;amp;matched. out = smatched(keep=BENE_ID matchto);
   by ID;
run;

data tcases(drop=matchto);
   merge sumcase(in = in1)
         smatched;
   by ID;
   if in1 and matchto = .;
   cmatch = 0;
   aprob = round(prob,&amp;amp;digits.);
run;

data tctrl(drop=matchto);
     merge sumcontrol(in = in1)
           smatched;
     by ID;
     if in1 and matchto = .;
     cmatch = 0;
     cprob = round(prob,&amp;amp;digits.);
run;

%sortcc;
%mend match;

%initcc(.000001);

%match(match5,.00001);
%match(match4,.0001);
%match(match3,.001);
%match(match2,.01);
%match(match1,.1);

data &amp;amp;lib..&amp;amp;matches.;
     set &amp;amp;lib..match5(in = a)
         &amp;amp;lib..match4(in = b)
         &amp;amp;lib..match3(in = c)
         &amp;amp;lib..match2(in = d)
         &amp;amp;lib..match1(in = e);
	 if a then matchto = matchto + 1000;
     if b then matchto = matchto + 100000;
     if c then matchto = matchto + 10000000;
     if d then matchto = matchto + 1000000000;
     if e then matchto = matchto + 100000000000;
run;

proc sort data = &amp;amp;lib..&amp;amp;matches. out = &amp;amp;lib..s&amp;amp;matches.;
     by &amp;amp;depend.;
run;

%mend greedmtch;
%GREEDMTCH( Lib=PERM, Dataset=BOOTSAMPLEPS, depend=EXPOSURE, matches=BOOTSAMPLEPSMATCH);


PROC SORT DATA=PERM.BOOTSAMPLEPSMATCH OUT=PERM.BOOTSAMPLEPSMATCH1; 
BY ID REPLICATE; 
RUN;

PROC PHREG DATA=PERM.BOOTSAMPLEPSMATCH1;
BY REPLICATE;
CLASS EXPOSURE /PARAM=REF REF=FIRST;
MODEL  TIMETOEVENT * CENSOR(0) = EXPOSURE /RL;
STRATA MATCHTO;
TITLE "PROPENSITY-SCORE MATCHED BOOTSTRAPPED COX MODEL";
RUN;&lt;/CODE&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2019 20:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556563#M155031</guid>
      <dc:creator>schatterjee</dc:creator>
      <dc:date>2019-05-06T20:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS codes for bootstrapping for propensity score matched sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556565#M155032</link>
      <description>PROC PSMATCH will do greedy matching for you.</description>
      <pubDate>Mon, 06 May 2019 20:24:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556565#M155032</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-06T20:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS codes for bootstrapping for propensity score matched sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556569#M155033</link>
      <description>Thanks Reeza! Can you suggest a way to resolve the error on bootstrapping in the final step on regression?</description>
      <pubDate>Mon, 06 May 2019 20:29:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556569#M155033</guid>
      <dc:creator>schatterjee</dc:creator>
      <dc:date>2019-05-06T20:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS codes for bootstrapping for propensity score matched sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556579#M155039</link>
      <description>Sorry, I have no idea what the error is. I can't run your code (no data), there are no comments to let me know what you thought was happening and you didn't include the log or error.</description>
      <pubDate>Mon, 06 May 2019 21:36:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556579#M155039</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-06T21:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS codes for bootstrapping for propensity score matched sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556580#M155040</link>
      <description>Sorry, you did include the error but didn't indicate which step generates it.</description>
      <pubDate>Mon, 06 May 2019 21:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556580#M155040</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-06T21:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS codes for bootstrapping for propensity score matched sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556584#M155042</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;I received the error at the proc phreg step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Satabdi&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2019 21:48:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556584#M155042</guid>
      <dc:creator>schatterjee</dc:creator>
      <dc:date>2019-05-06T21:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS codes for bootstrapping for propensity score matched sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556588#M155046</link>
      <description>Why did you sort by ID? Is that needed? The error is because the BY statement is different between the sort and the PROC PHREG.</description>
      <pubDate>Mon, 06 May 2019 22:00:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556588#M155046</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-06T22:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS codes for bootstrapping for propensity score matched sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556590#M155048</link>
      <description>Thanks so much Reeza! Let me try without id and see what I get.</description>
      <pubDate>Mon, 06 May 2019 22:04:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556590#M155048</guid>
      <dc:creator>schatterjee</dc:creator>
      <dc:date>2019-05-06T22:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS codes for bootstrapping for propensity score matched sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556595#M155050</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272816"&gt;@schatterjee&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;I received the error at the proc phreg step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Satabdi&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Fairly clear error:&lt;/P&gt;
&lt;PRE&gt;ERROR: Data set PERM.BOOTSAMPLEPSMATCH1 is not sorted in ascending sequence.&lt;/PRE&gt;
&lt;P&gt;In&lt;/P&gt;
&lt;PRE&gt;PROC PHREG DATA=PERM.BOOTSAMPLEPSMATCH1;
&lt;FONT color="#ff0000"&gt;BY REPLICATE;&amp;lt;= NOT sorted properly here
&lt;/FONT&gt;CLASS EXPOSURE /PARAM=REF REF=FIRST;
MODEL  TIMETOEVENT * CENSOR(0) = EXPOSURE /RL;
STRATA MATCHTO;
TITLE "PROPENSITY-SCORE MATCHED BOOTSTRAPPED COX MODEL";
RUN;  &lt;/PRE&gt;
&lt;P&gt;So sort the data set BY REPLICATE prior to the Proc Phreg.&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2019 22:13:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556595#M155050</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-06T22:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS codes for bootstrapping for propensity score matched sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556596#M155051</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;I redid the analyses, and that error was resolved. This time I received a warning "Convergence was not attained in 25 iterations". Also for the final output, all the fields (parameter estimate, std error, 95% CI, Chi-Sq, Pr&amp;gt;Chi-sq, HR, 95% CI of HR) are blank. Is it because convergence was not attained?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Satabdi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2019 22:14:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556596#M155051</guid>
      <dc:creator>schatterjee</dc:creator>
      <dc:date>2019-05-06T22:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS codes for bootstrapping for propensity score matched sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556599#M155053</link>
      <description>Thanks!</description>
      <pubDate>Mon, 06 May 2019 22:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556599#M155053</guid>
      <dc:creator>schatterjee</dc:creator>
      <dc:date>2019-05-06T22:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS codes for bootstrapping for propensity score matched sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556607#M155058</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272816"&gt;@schatterjee&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;I redid the analyses, and that error was resolved. This time I received a warning "Convergence was not attained in 25 iterations". Also for the final output, all the fields (parameter estimate, std error, 95% CI, Chi-Sq, Pr&amp;gt;Chi-sq, HR, 95% CI of HR) are blank. Is it because convergence was not attained?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Satabdi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, but that's likely due to a data issue. Check that you have enough data, and that you don't have 0 cells in your categorical data.&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2019 22:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556607#M155058</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-06T22:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: SAS codes for bootstrapping for propensity score matched sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556614#M155062</link>
      <description>Ok thank you so much for your help!</description>
      <pubDate>Mon, 06 May 2019 23:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-codes-for-bootstrapping-for-propensity-score-matched-sample/m-p/556614#M155062</guid>
      <dc:creator>schatterjee</dc:creator>
      <dc:date>2019-05-06T23:08:55Z</dc:date>
    </item>
  </channel>
</rss>

