<?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: Similar to moving percentile question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Similar-to-moving-percentile-question/m-p/141773#M296682</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You mean look forward ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data have;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do value=1 to 1000;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;
run;

data want;
 set have nobs=nobs;
 array x{99999} _temporary_;
 do i=_n_+1 to min(nobs,_n_+499);
&amp;nbsp; set have(rename=(value=v)) point=i;
&amp;nbsp; x{i}=v;
 end;
 _25th=largest(25,of x{*});
 call missing(of x{*});
 drop i v;
run;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 14 Dec 2014 10:46:33 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2014-12-14T10:46:33Z</dc:date>
    <item>
      <title>Similar to moving percentile question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Similar-to-moving-percentile-question/m-p/141768#M296677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everyone, &lt;/P&gt;&lt;P&gt;I want to do a process similar to finding moving percentile.&lt;/P&gt;&lt;P&gt;However, for each record, I want to look back 500 records (excluding the current record) and extract the value of the 475&lt;SUP&gt;th&lt;/SUP&gt; largest record (it is not the same as 95 percentile in SAS).&lt;/P&gt;&lt;P&gt;I prefer this way to percentile since it is comparable with other software I use and I can control the value better.&lt;/P&gt;&lt;P&gt;So for the data below, for the first record, the value-475 should be 476.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HHC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have; &lt;/P&gt;&lt;P&gt;do value=1 to 1000;output; end;&lt;/P&gt;&lt;P&gt;;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Dec 2014 20:26:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Similar-to-moving-percentile-question/m-p/141768#M296677</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2014-12-08T20:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: Similar to moving percentile question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Similar-to-moving-percentile-question/m-p/141769#M296678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you mean 25th largest?&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; value=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1000&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; t(&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;:&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;499&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;_temporary_&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t(mod(_n_,&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;500&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;))=value;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _n_&amp;gt;&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;499&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _25th=largest(&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;25&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;,of t(*));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;Haikuo &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Dec 2014 20:50:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Similar-to-moving-percentile-question/m-p/141769#M296678</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-12-08T20:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Similar to moving percentile question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Similar-to-moving-percentile-question/m-p/141770#M296679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;It is almost what I want.&lt;/P&gt;&lt;P&gt;However, the first record value for _25th should be 476.&lt;/P&gt;&lt;P&gt;file want should look like:&lt;/P&gt;&lt;P&gt;value&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _25th&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 476&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 477&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HHC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Dec 2014 21:18:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Similar-to-moving-percentile-question/m-p/141770#M296679</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2014-12-08T21:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: Similar to moving percentile question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Similar-to-moving-percentile-question/m-p/141771#M296680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This?&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;array t(0:499) _temporary_;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;t(mod(_n_,500))=value;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if _n_&amp;gt;499 then do;&lt;/P&gt;&lt;P&gt;_25th=largest(25,of t(*));&lt;/P&gt;&lt;P&gt;n+1;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop value;&lt;/P&gt;&lt;P&gt;rename n=value;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Dec 2014 21:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Similar-to-moving-percentile-question/m-p/141771#M296680</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-12-08T21:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Similar to moving percentile question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Similar-to-moving-percentile-question/m-p/141772#M296681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes it is the what I want. But I want to keep the original 1000 records. Right now the last 499 records are gone.&lt;/P&gt;&lt;P&gt;If I have to do DO LOOP through this code, each time, the data is reduced by 499.&lt;/P&gt;&lt;P&gt;HHC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Dec 2014 21:55:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Similar-to-moving-percentile-question/m-p/141772#M296681</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2014-12-08T21:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Similar to moving percentile question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Similar-to-moving-percentile-question/m-p/141773#M296682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You mean look forward ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data have;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do value=1 to 1000;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;
run;

data want;
 set have nobs=nobs;
 array x{99999} _temporary_;
 do i=_n_+1 to min(nobs,_n_+499);
&amp;nbsp; set have(rename=(value=v)) point=i;
&amp;nbsp; x{i}=v;
 end;
 _25th=largest(25,of x{*});
 call missing(of x{*});
 drop i v;
run;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Dec 2014 10:46:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Similar-to-moving-percentile-question/m-p/141773#M296682</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-12-14T10:46:33Z</dc:date>
    </item>
  </channel>
</rss>

