<?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: Trimming the top and bottom 5% of a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295704#M61829</link>
    <description>&lt;P&gt;Yes, please. &amp;nbsp;IML code, too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a million!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Sep 2016 07:14:47 GMT</pubDate>
    <dc:creator>NKormanik</dc:creator>
    <dc:date>2016-09-01T07:14:47Z</dc:date>
    <item>
      <title>Trimming the top and bottom 5% of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295688#M61823</link>
      <description>&lt;P&gt;From another similar question on these boards I found the following solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let trim=0.05;
data trimmed;
set have
Nobs=NN;
if &amp;amp;trim*NN &amp;lt; _N_ &amp;lt;= (1-&amp;amp;trim)*NN
then output;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;1) &amp;nbsp;Do you concur with this way of trimming the tails? &amp;nbsp;(I'm not exactly sure what's going on with this. &amp;nbsp;Just want it to work.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) &amp;nbsp;Data needs to be sorted by the relevant variable we want to trim, yes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nicholas Kormanik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2016 05:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295688#M61823</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-09-01T05:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Trimming the top and bottom 5% of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295689#M61824</link>
      <description>&lt;P&gt;Depends. Rules of 5% is vague, and often confused with percentiles.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So define your rules first.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2016 05:19:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295689#M61824</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-01T05:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Trimming the top and bottom 5% of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295694#M61825</link>
      <description>&lt;P&gt;The approach I'm presently using is the manual, long-about way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First running Proc Univariate I am obtaining the _P5_ and _P95_ actual numbers (say, 30 and 156).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I then plug these numbers into the following code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tails_trimmed_5_percent;
set have;
where 30 &amp;lt;= N &amp;lt;= 156;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have many such databases. &amp;nbsp;And I was thinking there might be a more direct general approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Such as, just imagining, mind you....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where (lower_tail_5_percent) &amp;lt;= N &amp;lt;= (upper_tail_5_percent);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, appears life ain't that easy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2016 06:29:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295694#M61825</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-09-01T06:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: Trimming the top and bottom 5% of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295702#M61828</link>
      <description>&lt;PRE&gt;

A fast way to get it is using proc rank:

proc rank data=sashelp.cars groups=100 out=temp;
 var invoice;
 ranks rank;
run;
data want;
 set temp;
 if 5 &amp;lt; rank &amp;lt; 95 ;
run;

Another way is using IML, you want IML code ?

&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Sep 2016 07:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295702#M61828</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-01T07:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Trimming the top and bottom 5% of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295704#M61829</link>
      <description>&lt;P&gt;Yes, please. &amp;nbsp;IML code, too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a million!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2016 07:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295704#M61829</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-09-01T07:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Trimming the top and bottom 5% of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295710#M61830</link>
      <description>&lt;PRE&gt;
Here is . I set the value greater than 95th or less than 5th be missing .


data have;
 do i=1 to 100;
  a=ceil(ranuni(1)*100);
  b=ceil(ranuni(2)*100);
  output;
 end;
 drop i;
run;


%let low=0.05 ;
%let high=0.95 ;

proc iml;
use have;
read all var _num_ into x[c=vname];
close have;
call qntl(q,x,{&amp;amp;low ,&amp;amp;high});

do i=1 to ncol(x);
 x[loc(x[,i]&lt;Q&gt;q[2,i]),i]=.;
end;

create want from x[c=vname];
append from x;
close want;

quit;
&lt;/Q&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Sep 2016 07:43:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295710#M61830</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-01T07:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Trimming the top and bottom 5% of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295716#M61832</link>
      <description>&lt;PRE&gt;
Opps. should use 


proc rank data=sashelp.cars groups=100 out=temp ;
 var invoice;
 ranks rank;
run;
data want;
 set temp;
 if 4 &amp;lt; rank &amp;lt; 94 ;
run;


Due to the fact that rank is 0-99 .


&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Sep 2016 07:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trimming-the-top-and-bottom-5-of-a-dataset/m-p/295716#M61832</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-01T07:58:18Z</dc:date>
    </item>
  </channel>
</rss>

