<?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: Make a loop to calculate bootstrap 95% CI for median in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Make-a-loop-to-calculate-bootstrap-95-CI-for-median/m-p/806520#M317777</link>
    <description>&lt;P&gt;You could do this yourself, or you could use the existing %BOOT and %BOOTCI macros, and save yourself a lot of programming time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/07/23/boot-and-bootci-macros-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/07/23/boot-and-bootci-macros-sas.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Apr 2022 14:11:28 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-04-07T14:11:28Z</dc:date>
    <item>
      <title>Make a loop to calculate bootstrap 95% CI for median</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-a-loop-to-calculate-bootstrap-95-CI-for-median/m-p/806518#M317775</link>
      <description>&lt;P&gt;I got the following code from online and was wondering if there was a way to efficiently run it multiple times with different combinations of PARAMN, APHASE, and DAYN. I assume a do loop will get me there but I am not at all familiar with how to set one up.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let NumSamples = 1000;

data sample;
 set _trt_;
 where paramn = 1 and aphase = 'CHMI 1' and dayn = 1;
 keep aval;

proc surveyselect data= sample noprint seed= 1
 out= _boot_ (rename= (replicate = sampleid))
 method= urs		/*resample with replacement*/
 samprate= 1 		/*each bootstrap sample has N observations*/
 reps= &amp;amp;NumSamples;	/*generate # bootstrap resamples*/

proc means data= _boot_ noprint;
 by sampleid;
 freq NumberHits;
 var aval;
 output out= _boot_med_ median= med;

proc univariate data= _boot_med_ noprint;
 var med;
 output out= _95ci_ pctlpre= CI95_ 
 		pctlpts= 2.5 97.5
		pctlname= lb ub;

data _111;
 set _95ci_;
 	statn= 5;
	ci = strip(lb)||', '||strip(ub);
 	paramn = 1; aphase = 'CHMI 1'; dayn = 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Mock Dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have0;
 input usubjid $ paramn aphase $ dayn aval @@;
 cards;
 A	1	CHMI1	1	0.45
 A	1	CHMI1	2	0.36
 A	1	CHMI1	3	0.66
 A	2	CHMI1	1	0.25
 A	2	CHMI1	2	0.58
 A	2	CHMI1	3	0.55
 A	2	CHMI1	4	0.65
 A	3	CHMI1	1	0.25
 A	3	CHMI1	2	0.85
 A	1	CHMI2	1	0.12
 A	1	CHMI2	2	0.54
 A	1	CHMI2	3	0.98
 A	2	CHMI2	1	0.13
 A	3	CHMI2	1	0.21
 A	3	CHMI2	2	0.48
 ;
run;

data have;
 set have0; output;
 set have0; usubjid = 'B'; aval = aval + 0.05; output;
 set have0; usubjid = 'C'; aval = aval - 0.1; output;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 14:09:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-a-loop-to-calculate-bootstrap-95-CI-for-median/m-p/806518#M317775</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2022-04-07T14:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: Make a loop to calculate bootstrap 95% CI for median</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-a-loop-to-calculate-bootstrap-95-CI-for-median/m-p/806519#M317776</link>
      <description>EDIT: the sample dataset will come from HAVE not _TRT_ in this case</description>
      <pubDate>Thu, 07 Apr 2022 14:10:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-a-loop-to-calculate-bootstrap-95-CI-for-median/m-p/806519#M317776</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2022-04-07T14:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Make a loop to calculate bootstrap 95% CI for median</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-a-loop-to-calculate-bootstrap-95-CI-for-median/m-p/806520#M317777</link>
      <description>&lt;P&gt;You could do this yourself, or you could use the existing %BOOT and %BOOTCI macros, and save yourself a lot of programming time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/07/23/boot-and-bootci-macros-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/07/23/boot-and-bootci-macros-sas.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 14:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-a-loop-to-calculate-bootstrap-95-CI-for-median/m-p/806520#M317777</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-07T14:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Make a loop to calculate bootstrap 95% CI for median</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-a-loop-to-calculate-bootstrap-95-CI-for-median/m-p/806526#M317779</link>
      <description>&lt;P&gt;Although that would help me reduce the bootstrap code itself down, I would still need to create different combinations of PARAMN, APHASE, and DAYN to get all the 95% CI that I want. This is the main reason I would like to make a loop.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 14:25:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-a-loop-to-calculate-bootstrap-95-CI-for-median/m-p/806526#M317779</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2022-04-07T14:25:25Z</dc:date>
    </item>
  </channel>
</rss>

