<?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: Calculating bootstrapped 95% CI for 99th percentile of a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculating-bootstrapped-95-CI-for-99th-percentile-of-a-variable/m-p/931183#M366350</link>
    <description>&lt;P&gt;I can't tell you for sure why you are getting that behavior. However, I will point out that, in general, bootstrapping is known to provide poor estimates of the sampling distribution of extreme order statistics. Textbook examples are the minimum and maximum. I suspect that will also be true for the 99th percentile, so I would encourage you to think carefully about whether to even use a bootstrap here.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jun 2024 19:46:54 GMT</pubDate>
    <dc:creator>Mike_N</dc:creator>
    <dc:date>2024-06-06T19:46:54Z</dc:date>
    <item>
      <title>Calculating bootstrapped 95% CI for 99th percentile of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-bootstrapped-95-CI-for-99th-percentile-of-a-variable/m-p/931158#M366341</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried using the bootstrapping method described by&amp;nbsp;Rick Wicklin&amp;nbsp;&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2016/08/10/bootstrap-confidence-interval-sas.html" target="_self"&gt;here&lt;/A&gt; to calculate the 95% CI around my statistic of interest (the 99th percentile of a variable).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My sample size is about 3200 participants. I am planning to use 2000 replicates. However, when I ran the code (below), it returned CI that do not surround the initial 99th percentile. For example, the 99th percentile of the variable was 0.13 and the CI limits generated were 11.6 and 42.9. I think&amp;nbsp; Any thoughts on what I did wrong here? I added p99 to step 2, which was not in the original example, but is my statistic of interest.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sophie&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=mydata p99; &lt;BR /&gt;var myvar; &lt;BR /&gt;run; 

%let NumSamples = 2000;       /* number of bootstrap resamples */
/* 1. Generate many bootstrap samples */
proc surveyselect data=mydata NOPRINT seed=1
     out=BootSSFreq(rename=(Replicate=SampleID))
     method=urs              /* resample with replacement */
     samprate=1              /* each bootstrap sample has N observations */
     /*outhits*/ 			 /* OUTHITS option to suppress the frequency var */
     reps=&amp;amp;NumSamples;       /* generate NumSamples bootstrap resamples */
run;

/* 2. Compute the statistic for each bootstrap sample */
proc means data=BootSSFreq p99 noprint;
   by SampleID;
   freq NumberHits;
   var myvar;
   output out=OutStats skew=Skewness;  /* approx sampling distribution */
run;

/* 3. Use approx sampling distribution to make statistical inferences */
proc univariate data=OutStats noprint;
   var Skewness;
   output out=Pctl pctlpre =CI95_
          pctlpts =2.5  97.5       /* compute 95% bootstrap confidence interval */
          pctlname=Lower Upper;
run;
 
proc print data=Pctl noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jun 2024 15:30:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-bootstrapped-95-CI-for-99th-percentile-of-a-variable/m-p/931158#M366341</guid>
      <dc:creator>sophiec</dc:creator>
      <dc:date>2024-06-06T15:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating bootstrapped 95% CI for 99th percentile of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-bootstrapped-95-CI-for-99th-percentile-of-a-variable/m-p/931160#M366343</link>
      <description>&lt;P&gt;I tried updating the code as follows, as I think what I was calculating before was the 95% CI for the skewness of the variable and not the 99th percentile.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is correct, can I calculate bootstrapped CIs for subgroups of my data (for example, by sex)?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sophie&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let NumSamples = 2000; /* number of bootstrap resamples */
/* 1. Generate many bootstrap samples */
proc surveyselect data=cric NOPRINT seed=1
out=BootSSFreq(rename=(Replicate=SampleID))
method=urs /* resample with replacement */
samprate=1 /* each bootstrap sample has N observations */
outhits /* OUTHITS option to suppress the frequency var */
reps=&amp;amp;NumSamples; /* generate NumSamples bootstrap resamples */
run;

/* 2. Compute the statistic for each bootstrap sample */
proc means data=BootSSFreq p99 noprint;
by SampleID;
freq NumberHits;
var myvar;
output out=OutStats p99=percentile; /* approx sampling distribution */
run;

/* 3. Use approx sampling distribution to make statistical inferences */
proc univariate data=OutStats noprint;
var percentile;
output out=Pctl pctlpre =CI95_
pctlpts =2.5 97.5 /* compute 95% bootstrap confidence interval */
pctlname=Lower Upper;
run;

proc print data=Pctl noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jun 2024 15:50:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-bootstrapped-95-CI-for-99th-percentile-of-a-variable/m-p/931160#M366343</guid>
      <dc:creator>sophiec</dc:creator>
      <dc:date>2024-06-06T15:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating bootstrapped 95% CI for 99th percentile of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-bootstrapped-95-CI-for-99th-percentile-of-a-variable/m-p/931162#M366345</link>
      <description>&lt;P&gt;Rick's article was to find the interval around the SKEWNESS of a variable. So you copied his Proc Means Code asking for the same values&lt;/P&gt;
&lt;PRE&gt;proc means data=BootSSFreq p99 noprint;
   by SampleID;
   freq NumberHits;
   var myvar;
   output out=OutStats &lt;FONT size="5" color="#FF00FF"&gt;&lt;STRONG&gt;skew=Skewness&lt;/STRONG&gt;&lt;/FONT&gt;;  /* approx sampling distribution */
run;&lt;/PRE&gt;
&lt;P&gt;I think you want P99= and use that in univariate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/441111"&gt;@sophiec&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried using the bootstrapping method described by&amp;nbsp;Rick Wicklin&amp;nbsp;&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2016/08/10/bootstrap-confidence-interval-sas.html" target="_self"&gt;here&lt;/A&gt; to calculate the 95% CI around my statistic of interest (the 99th percentile of a variable).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My sample size is about 3200 participants. I am planning to use 2000 replicates. However, when I ran the code (below), it returned CI that do not surround the initial 99th percentile. For example, the 99th percentile of the variable was 0.13 and the CI limits generated were 11.6 and 42.9. I think&amp;nbsp; Any thoughts on what I did wrong here? I added p99 to step 2, which was not in the original example, but is my statistic of interest.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sophie&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=mydata p99; &lt;BR /&gt;var myvar; &lt;BR /&gt;run; 

%let NumSamples = 2000;       /* number of bootstrap resamples */
/* 1. Generate many bootstrap samples */
proc surveyselect data=mydata NOPRINT seed=1
     out=BootSSFreq(rename=(Replicate=SampleID))
     method=urs              /* resample with replacement */
     samprate=1              /* each bootstrap sample has N observations */
     /*outhits*/ 			 /* OUTHITS option to suppress the frequency var */
     reps=&amp;amp;NumSamples;       /* generate NumSamples bootstrap resamples */
run;

/* 2. Compute the statistic for each bootstrap sample */
proc means data=BootSSFreq p99 noprint;
   by SampleID;
   freq NumberHits;
   var myvar;
   output out=OutStats skew=Skewness;  /* approx sampling distribution */
run;

/* 3. Use approx sampling distribution to make statistical inferences */
proc univariate data=OutStats noprint;
   var Skewness;
   output out=Pctl pctlpre =CI95_
          pctlpts =2.5  97.5       /* compute 95% bootstrap confidence interval */
          pctlname=Lower Upper;
run;
 
proc print data=Pctl noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 16:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-bootstrapped-95-CI-for-99th-percentile-of-a-variable/m-p/931162#M366345</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-06T16:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating bootstrapped 95% CI for 99th percentile of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-bootstrapped-95-CI-for-99th-percentile-of-a-variable/m-p/931163#M366346</link>
      <description>&lt;P&gt;Use CLASS Varname; in the Proc Means and Proc Univariate to get subgroups. However depending on your distribution of values in the subgroup data you may need to change the sample size in Surveyselect to have large enough samples.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 16:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-bootstrapped-95-CI-for-99th-percentile-of-a-variable/m-p/931163#M366346</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-06T16:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating bootstrapped 95% CI for 99th percentile of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-bootstrapped-95-CI-for-99th-percentile-of-a-variable/m-p/931168#M366348</link>
      <description>&lt;P&gt;Thank you! I realized that shortly after posting and updated the code (see above). However, I'm finding that the calculated 99th percentile is not centered within the 95% CI that it calculates.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, see the following 99th percentiles with 95% CI:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;overall sample: 102.6 (55.0, 229.0)&lt;/P&gt;
&lt;P&gt;subgroup 1: 55.0 (17.0, 617.7)&lt;/P&gt;
&lt;P&gt;subgroup 2: 86.0 (36.7, 252.9)&lt;/P&gt;
&lt;P&gt;subgroup 3: 187.4 (57.9, 291.8)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 16:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-bootstrapped-95-CI-for-99th-percentile-of-a-variable/m-p/931168#M366348</guid>
      <dc:creator>sophiec</dc:creator>
      <dc:date>2024-06-06T16:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating bootstrapped 95% CI for 99th percentile of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-bootstrapped-95-CI-for-99th-percentile-of-a-variable/m-p/931183#M366350</link>
      <description>&lt;P&gt;I can't tell you for sure why you are getting that behavior. However, I will point out that, in general, bootstrapping is known to provide poor estimates of the sampling distribution of extreme order statistics. Textbook examples are the minimum and maximum. I suspect that will also be true for the 99th percentile, so I would encourage you to think carefully about whether to even use a bootstrap here.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 19:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-bootstrapped-95-CI-for-99th-percentile-of-a-variable/m-p/931183#M366350</guid>
      <dc:creator>Mike_N</dc:creator>
      <dc:date>2024-06-06T19:46:54Z</dc:date>
    </item>
  </channel>
</rss>

