<?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: Winsorizing variables with missing observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Winsorizing-variables-with-missing-observations/m-p/423588#M104183</link>
    <description>&lt;P&gt;If you have SAS/IML .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 do i=1 to 100;
  a=ceil(ranuni(1)*100);
  b=ceil(ranuni(2)*100);
  if i in (10:14) then call missing(a);
  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]&amp;lt;q[1,i]),i]=q[1,i];
 x[loc(x[,i]&amp;gt;q[2,i]),i]=q[2,i];
end;

create want from x[c=vname];
append from x;
close want;

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 26 Dec 2017 14:25:26 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-12-26T14:25:26Z</dc:date>
    <item>
      <title>Winsorizing variables with missing observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Winsorizing-variables-with-missing-observations/m-p/423543#M104171</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set containing&amp;nbsp;three variables and I want to winsorize them at 1% and 99%. Moreover, I need to replace the observations which are less than 1% with the observation at 1%, likewise replace the observations which are greater than 99% with the observation at 99%.&lt;/P&gt;&lt;P&gt;These&amp;nbsp;three variables have missing as well as repeated observations. I am using the code below but due to missing and repeated observations, it does not give required&amp;nbsp;outcome.&lt;/P&gt;&lt;P&gt;Please guide me in this regard.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let L=1;    
%let H=%eval(100 - &amp;amp;L);   %* 99th percentile*;
proc univariate data=have noprint;
   var Size BM ME;
   output out=_winsor   pctlpts=&amp;amp;L  &amp;amp;H    
   pctlpre=__Size  __BM  __ME;
run;
data want (drop=__:);
  set have;
  if _n_=1 then set _winsor;
  array wlo  {*} __Size&amp;amp;L  __BM&amp;amp;L   __ME&amp;amp;L;
  array whi  {*} __Size&amp;amp;H __BM&amp;amp;H __ME&amp;amp;H;
  array wval {*} wSize wBM wME;
  array val   {*} Size BM ME;
  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>Tue, 26 Dec 2017 05:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Winsorizing-variables-with-missing-observations/m-p/423543#M104171</guid>
      <dc:creator>Saba1</dc:creator>
      <dc:date>2017-12-26T05:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Winsorizing variables with missing observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Winsorizing-variables-with-missing-observations/m-p/423588#M104183</link>
      <description>&lt;P&gt;If you have SAS/IML .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 do i=1 to 100;
  a=ceil(ranuni(1)*100);
  b=ceil(ranuni(2)*100);
  if i in (10:14) then call missing(a);
  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]&amp;lt;q[1,i]),i]=q[1,i];
 x[loc(x[,i]&amp;gt;q[2,i]),i]=q[2,i];
end;

create want from x[c=vname];
append from x;
close want;

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Dec 2017 14:25:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Winsorizing-variables-with-missing-observations/m-p/423588#M104183</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-12-26T14:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Winsorizing variables with missing observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Winsorizing-variables-with-missing-observations/m-p/423677#M104222</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;thanks fro the help. but this code replaces the missing observations with the values at P5 or P95. I want to keep missing observations as missing.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 04:45:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Winsorizing-variables-with-missing-observations/m-p/423677#M104222</guid>
      <dc:creator>Saba1</dc:creator>
      <dc:date>2017-12-27T04:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Winsorizing variables with missing observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Winsorizing-variables-with-missing-observations/m-p/423718#M104234</link>
      <description>&lt;P&gt;OK. No problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 do i=1 to 100;
  a=ceil(ranuni(1)*100);
  b=ceil(ranuni(2)*100);
  if i in (10:14) then do;call missing(a); b=100;end;
  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]&amp;lt;q[1,i] &amp;amp; x[,i]^=.),i]=q[1,i];
 x[loc(x[,i]&amp;gt;q[2,i]),i]=q[2,i];
end;

create want from x[c=vname];
append from x;
close want;

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Dec 2017 12:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Winsorizing-variables-with-missing-observations/m-p/423718#M104234</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-12-27T12:45:36Z</dc:date>
    </item>
  </channel>
</rss>

