<?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: How to obtain sum of 2.5th-97.5th percentile? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/890193#M351751</link>
    <description>Yes, you are right.&lt;BR /&gt;</description>
    <pubDate>Mon, 21 Aug 2023 13:17:12 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2023-08-21T13:17:12Z</dc:date>
    <item>
      <title>How to obtain sum of 2.5th-97.5th percentile?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889934#M351611</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;How to get the obs between 2.5% and 97.5% percentile of the sum in the dataset?&amp;nbsp; The sum is in dollar 10.2 format. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 17:24:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889934#M351611</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2023-08-18T17:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain sum of 2.5th-97.5th ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889936#M351612</link>
      <description>&lt;P&gt;I assume you mean PERCENTILE, but you did not say that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that is correct, then this makes sense "How to get the obs between 2.5% and 97.5%" but the next words "of the sum" make no sense in this context. Please explain further.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 16:57:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889936#M351612</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-18T16:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain sum of 2.5th-97.5th ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889937#M351613</link>
      <description>&lt;P&gt;percentile&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 16:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889937#M351613</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2023-08-18T16:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain sum of 2.5th-97.5th ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889942#M351615</link>
      <description>&lt;P&gt;I asked for an explanation, I don't see one.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 17:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889942#M351615</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-18T17:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain sum of 2.5th-97.5th ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889943#M351616</link>
      <description>&lt;P&gt;If you mean "sum the values of the observations between the 2.5th and 97.5 percentiles of the variable"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steps: 1) determine the given percentiles, Proc univariate may be best here.&lt;/P&gt;
&lt;P&gt;2) filter the data with a Where statement or data set option using the values of the percentiles&lt;/P&gt;
&lt;P&gt;3) sum the variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 17:29:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889943#M351616</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-18T17:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain sum of 2.5th-97.5th percentile?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889949#M351620</link>
      <description>So which part do you not understand, calculating the percentiles, filtering the data or calculating the sum?</description>
      <pubDate>Fri, 18 Aug 2023 17:41:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889949#M351620</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-08-18T17:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain sum of 2.5th-97.5th percentile?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889970#M351631</link>
      <description>&lt;P&gt;I am going to assume that you have a variable in your data set named "Sum", and that you want the observations in the middle 95th percentile of that variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* generate some example datas */
data Have;
format Sum DOLLAR10.2;
do i = 1 to 100;
   Sum = 1000*i;
   output;
end;

/* Find the 2.5th and 97.5th percentiles for the SUM variable */
proc univariate data=Have noprint;
   var Sum;
   output out=Pctls pctlpre=Pctl_ pctlpts=2.5, 97.5; 
run;

/* copy the lower and upper pctl value into macro variables */
data _null_;
   set Pctls;
   call symputx("LowerPctl", Pctl_2_5);
   call symputx("UpperPctl", Pctl_97_5);
run;

/* extract the middle 95% of the data */
data Middle;
set Have;
where &amp;amp;LowerPctl &amp;lt;= Sum and Sum &amp;lt;= &amp;amp;UpperPctl;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;If you want the sum of these values, you can use PROC MEANS:&lt;BR /&gt;&lt;STRONG&gt;proc means data=middle SUM;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;var Sum;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 18:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889970#M351631</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-08-18T18:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain sum of 2.5th-97.5th percentile?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889986#M351643</link>
      <description>&lt;P&gt;Is your data already sorted?&amp;nbsp; &amp;nbsp;If so, you can use the metadata item NOBS (number of obs in the dataset) to generate an upper and lower bound for observations to be submitted to the summing process:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select nobs, floor(nobs/40)+1) , floor(nobs-nobs/40)
    into :nobs, :LOWER_BOUND     , :UPPER_BOUND
  from dictionary.tables  where libname='WORK' and memname='HAVE';
quit;

%put &amp;amp;=nobs  &amp;amp;=lower_bound &amp;amp;=upper_bound;

proc means data=have (firstobs=&amp;amp;lower_bound  obs=&amp;amp;upper_bound)  sum n min max;
  var x;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To be precise, this code EXCLUDES as close to the lower and upper 2.5% that is achievable, but never excludes less than the upper and lower 2.5 percent.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 22:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/889986#M351643</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-08-18T22:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain sum of 2.5th-97.5th percentile?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/890193#M351751</link>
      <description>Yes, you are right.&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Aug 2023 13:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-obtain-sum-of-2-5th-97-5th-percentile/m-p/890193#M351751</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2023-08-21T13:17:12Z</dc:date>
    </item>
  </channel>
</rss>

