<?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: Traditional winsorize variables with missing observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Traditional-winsorize-variables-with-missing-observation/m-p/717488#M221895</link>
    <description>&lt;P&gt;MIN/MAX() functions ignore missing so you should &lt;STRONG&gt;test your assumption&lt;/STRONG&gt;. Make up some sample data and see what happens when you have missing values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FYI - if it is an issue, the fix is a single IF statement to add some conditional logic. Once you have a use case to test, you can easily test various IF conditions to get the one you need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;And we all know that the value of a missing variable is always the smallest so I have the feeling that this code above will not work properly with a variable that has missing observations?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Mon, 08 Feb 2021 04:42:17 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-02-08T04:42:17Z</dc:date>
    <item>
      <title>Traditional winsorize variables with missing observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Traditional-winsorize-variables-with-missing-observation/m-p/717476#M221888</link>
      <description>&lt;P&gt;Hi SAS&amp;nbsp; Users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I come to the winsorizing stage at 1% level (replace the value from 99% to 100% by the value at 99%, and replacing the value lower than 1% by value at 1%).&lt;/P&gt;
&lt;P&gt;And when using the code customized by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;in 2012, it still works really well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I already test with the dataset &lt;STRONG&gt;sashelp.shoes&lt;/STRONG&gt; for variables &lt;STRONG&gt;sales&lt;/STRONG&gt; and &lt;STRONG&gt;Inventory&lt;/STRONG&gt; and it works perfectly so far&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let L=1;    %* 1th percentile *;

%let H=%eval(100 - &amp;amp;L);   %* 99th percentile*;


proc univariate data=sashelp.shoes noprint;

   var sales Inventory;

   output out=_winsor   pctlpts=&amp;amp;L  &amp;amp;H     pctlpre=__sales __Inventory ;

run;

data want (drop=__:);

  set sashelp.shoes;

  if _n_=1 then set _winsor;

  array wlo  {*} __sales&amp;amp;L __Inventory&amp;amp;L  ;

  array whi  {*} __sales&amp;amp;H __Inventory&amp;amp;H ;

  array wval {*} wsales wInventory ;

  array val   {*} sales Inventory ;

  do _V=1 to dim(val);

     wval{_V}=min(max(val{_V},wlo{_V}),whi{_V});

  end;

run;

ods output Quantiles=outlier1;
proc univariate data=want;
var wsales wInventory;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But the dataset &lt;STRONG&gt;sashelp.shoes&lt;/STRONG&gt; contains no missing observation regarding the variables &lt;STRONG&gt;sales&lt;/STRONG&gt; and &lt;STRONG&gt;Inventory&lt;/STRONG&gt; but it is not always the case in reality.&lt;/P&gt;
&lt;P&gt;And we all know that the value of a missing variable is always the smallest so I have the feeling that this code above will not work properly with a variable that has missing observations?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I am wondering if there is any way to adjust the code above to winsorize the variables sales(assuming the variable sales has missing observation) but just with the numeric observations (do not care about the missing observations).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks and warm regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 02:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Traditional-winsorize-variables-with-missing-observation/m-p/717476#M221888</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-02-08T02:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Traditional winsorize variables with missing observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Traditional-winsorize-variables-with-missing-observation/m-p/717488#M221895</link>
      <description>&lt;P&gt;MIN/MAX() functions ignore missing so you should &lt;STRONG&gt;test your assumption&lt;/STRONG&gt;. Make up some sample data and see what happens when you have missing values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FYI - if it is an issue, the fix is a single IF statement to add some conditional logic. Once you have a use case to test, you can easily test various IF conditions to get the one you need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;And we all know that the value of a missing variable is always the smallest so I have the feeling that this code above will not work properly with a variable that has missing observations?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 08 Feb 2021 04:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Traditional-winsorize-variables-with-missing-observation/m-p/717488#M221895</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-08T04:42:17Z</dc:date>
    </item>
  </channel>
</rss>

