<?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 winsorize variable using SAS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94199#M26671</link>
    <description>&lt;P&gt;That's because in this small sample the 99%ile and 1%ile are at the max and min of the variables, so the winsorizing values were already at the extremes.&amp;nbsp; Add more observations or change the percentiles (but if you change the percentiles, modify the names of the variables in the WLO and WHI arrays correspondingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also you mistakenly generated the 10%ile instead of the first pecentile in the univariate procedure but that had no effect because the data step was looking for __size1, (but the actual variable created was __size10).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will change to the 10th and 90th percentiles which should produce results in your example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Editor's note: including original code solution in this message for convenience:&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two steps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;1. find the winsor low and high percentiles (PROC UNIVARIATE)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;2. truncate outliers to those values (DATA step)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let L=10;    %* 10th percentile *;
%let H=%eval(100 - &amp;amp;L);   %* 90th percentile*;
proc univariate data=have noprint;
   var size sales assets;
   output out=_winsor   pctlpts=&amp;amp;L  &amp;amp;H    
   pctlpre=__size  __sales  __assets;
run;
data want (drop=__:);
  set have;
  if _n_=1 then set _winsor;
  array wlo  {*} __size&amp;amp;L  __sales&amp;amp;L   __assets&amp;amp;L;
  array whi  {*} __size&amp;amp;H __sales&amp;amp;H __assets&amp;amp;H;
  array wval {*} wsize wsales wassets;
  array val   {*} size sales assets;
  do _V=1 to dim(val);
     wval{_V}=min(max(val{_V},wlo{_V}),whi{_V});
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 23 Jan 2017 15:56:55 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-01-23T15:56:55Z</dc:date>
    <item>
      <title>how to winsorize variable using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94195#M26667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I did know how to winsorize in Stata, but how to do it in SAS.&lt;/P&gt;&lt;P&gt;For example, I have three variables: size, sales, total assets&lt;/P&gt;&lt;P&gt;I want winsorize at the 1% and 99%, i.e. values that are less than the value at 1% are replaced by the value at 1%, and values that are greater than the value at 99% are replaced by the value at 99%. I don't want obs. with outliers are deleted.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 11:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94195#M26667</guid>
      <dc:creator>comeon2012</dc:creator>
      <dc:date>2012-08-15T11:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to winsorize variable using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94196#M26668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;lTwo steps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 1. find the winsor low and high percentiles&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 2. truncate outliers to those values&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let L=10;&amp;nbsp;&amp;nbsp;&amp;nbsp; %* 10th percentile *;&lt;/P&gt;&lt;P&gt;%let H=%eval(100 - &amp;amp;L);&amp;nbsp;&amp;nbsp; %* 90th percentile*;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc univariate data=have noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var size sales assets;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=_winsor&amp;nbsp;&amp;nbsp; pctlpts=&amp;amp;L&amp;nbsp; &amp;amp;H&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pctlpre=__size&amp;nbsp; __sales&amp;nbsp; __assets;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then set _winsor;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array wlo&amp;nbsp; {*} __size&amp;amp;L&amp;nbsp; __sales&amp;amp;L&amp;nbsp;&amp;nbsp; __assets&amp;amp;L;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array whi&amp;nbsp; {*} __size&amp;amp;H __sales&amp;amp;H __assets&amp;amp;H;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array wval {*} wsize wsales wassets;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array val&amp;nbsp;&amp;nbsp; {*} size sales assets;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _V=1 to dim(val);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wval{_V}=min(max(val{_V},wlo{_V}),whi{_V});&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;This can be easily macro-ized so that you can make parameters of the variable list, input/output data sets, and percentiles.&amp;nbsp; I suspect you may be a user of WRDS, given you are dealing with company-based financial data.&amp;nbsp; If so, you can find a more generalized winsorize macro via the RESEARCH tab on the WRDS web site.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 12:13:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94196#M26668</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2012-08-15T12:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to winsorize variable using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94197#M26669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A Google search brings me the following links, you may find them relevant:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://groups.google.com/forum/?fromgroups#%21topic/comp.soft-sys.sas/3xkmk4paP8E[1-25]" title="https://groups.google.com/forum/?fromgroups#%21topic/comp.soft-sys.sas/3xkmk4paP8E[1-25]"&gt;Google Groups&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="http://www.wrds.us/index.php/repository/view/1" title="http://www.wrds.us/index.php/repository/view/1"&gt;http://www.wrds.us/index.php/repository/view/1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 12:17:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94197#M26669</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-08-15T12:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to winsorize variable using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94198#M26670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;STRONG&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="-1" data-externalid="" data-presence="null" data-userid="808559" data-username="mkeintz" href="https://communities.sas.com/people/mkeintz" id="jive-80855945561569840119803"&gt;mkeintz&lt;/A&gt;&lt;/STRONG&gt;,&lt;/P&gt;&lt;P&gt;Problem again.&lt;/P&gt;&lt;P&gt;It seems that the winsor procedure does not make difference since values in want dataset(after winsorizing) is the same as have dataset(before winsorizing).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; size sales assets;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;10 3 15&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;20 5 20&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;30 5 23.2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;45 19 14.3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;2 3 16.4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;20 2 170&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;30 2 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;45 1 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;100 3 10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;20 3 25&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;39 3 30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;46 1 12&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;univariate&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;=have &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;noprint&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;var&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; size sales assets;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;output&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;=_winsor&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;pctlpts&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;99&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;pctlpre&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;=__size&amp;nbsp; __sales&amp;nbsp; __assets;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; want (drop=_:);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; _n_=&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; _winsor;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; wlo&amp;nbsp; {*} __size1 __sales1 __assets1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; whi&amp;nbsp; {*} __size99 __sales99 __assets99;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; wval {*} wsize wsales wassets;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; val&amp;nbsp;&amp;nbsp; {*} size sales assets;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; _V=&lt;/SPAN&gt;&lt;SPAN style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; dim(val);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wval{_V}=min(max(val{_V},wlo{_V}),whi{_V});&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 12:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94198#M26670</guid>
      <dc:creator>comeon2012</dc:creator>
      <dc:date>2012-08-15T12:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to winsorize variable using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94199#M26671</link>
      <description>&lt;P&gt;That's because in this small sample the 99%ile and 1%ile are at the max and min of the variables, so the winsorizing values were already at the extremes.&amp;nbsp; Add more observations or change the percentiles (but if you change the percentiles, modify the names of the variables in the WLO and WHI arrays correspondingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also you mistakenly generated the 10%ile instead of the first pecentile in the univariate procedure but that had no effect because the data step was looking for __size1, (but the actual variable created was __size10).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will change to the 10th and 90th percentiles which should produce results in your example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Editor's note: including original code solution in this message for convenience:&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two steps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;1. find the winsor low and high percentiles (PROC UNIVARIATE)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;2. truncate outliers to those values (DATA step)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let L=10;    %* 10th percentile *;
%let H=%eval(100 - &amp;amp;L);   %* 90th percentile*;
proc univariate data=have noprint;
   var size sales assets;
   output out=_winsor   pctlpts=&amp;amp;L  &amp;amp;H    
   pctlpre=__size  __sales  __assets;
run;
data want (drop=__:);
  set have;
  if _n_=1 then set _winsor;
  array wlo  {*} __size&amp;amp;L  __sales&amp;amp;L   __assets&amp;amp;L;
  array whi  {*} __size&amp;amp;H __sales&amp;amp;H __assets&amp;amp;H;
  array wval {*} wsize wsales wassets;
  array val   {*} size sales assets;
  do _V=1 to dim(val);
     wval{_V}=min(max(val{_V},wlo{_V}),whi{_V});
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2017 15:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94199#M26671</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-01-23T15:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to winsorize variable using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94200#M26672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you try to calculate Winsorized mean ? It is an example from documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;title 'Robust Estimates for Blood Pressure Data';
ods select TrimmedMeans WinsorizedMeans RobustScale;
proc univariate data=BPressure trimmed=1 .1
winsorized=.1 robustscale;
var Systolic;
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;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Aug 2012 02:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94200#M26672</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-08-16T02:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to winsorize variable using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94201#M26673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's my fault. Sorry for that.&lt;/P&gt;&lt;P&gt;Thanks anyway.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Aug 2012 02:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94201#M26673</guid>
      <dc:creator>comeon2012</dc:creator>
      <dc:date>2012-08-16T02:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to winsorize variable using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94202#M26674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found this answer very helpful, but I have a question for how to make it a little more specific to my needs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have data that I need to winsorize by quarter.&amp;nbsp; So, I have a large dataset with lots of values for each quarter, and I want to winsorize the top and bottom percent within each time period.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How could I modify the above code to make that happen?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 14:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94202#M26674</guid>
      <dc:creator>mahler_ji</dc:creator>
      <dc:date>2014-12-01T14:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to winsorize variable using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94203#M26675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Folks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have also a similar problem here! I have one continuous variable and it was not normally distributed - So I tried to take the square root of the variable and then winsorize at 5% and 95% - It was not normal again! So I went to winsorize at %7 and %97 - Then the variable was normally distributed!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, all the original significant associations from PROC GLM disappeared! can you guys please suggest me any solution for this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jan 2015 09:07:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94203#M26675</guid>
      <dc:creator>mantubiradar19</dc:creator>
      <dc:date>2015-01-15T09:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to winsorize variable using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94204#M26676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your question appears as an ANSWERED question on the Forum, which it is not. Post it as a new question (Discussion) on the SAS Statistical Procedures Community to attract more attention. - PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jan 2015 18:50:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94204#M26676</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-01-15T18:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to winsorize variable using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94205#M26677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure! Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2015 07:13:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-winsorize-variable-using-SAS/m-p/94205#M26677</guid>
      <dc:creator>mantubiradar19</dc:creator>
      <dc:date>2015-01-16T07:13:41Z</dc:date>
    </item>
  </channel>
</rss>

