<?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: Winsorized output file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Winsorized-output-file/m-p/529763#M144805</link>
    <description>&lt;P&gt;I don't believe that code actually writes back to the data set. It defines a function to winsorize and shows how it can be used. You would need to add the code to save it back to a data set. &lt;BR /&gt;&lt;BR /&gt;However, this question was asked at least once if not twice this week, so a quick search within the time frame should get you some generic examples.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/winsoring-outliers/m-p/529770#M144807" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/winsoring-outliers/m-p/529770#M144807&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jan 2019 17:36:08 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-01-24T17:36:08Z</dc:date>
    <item>
      <title>Winsorized output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Winsorized-output-file/m-p/529761#M144803</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using this code written by&amp;nbsp;&lt;A title="Posts by Rick Wicklin" href="https://blogs.sas.com/content/author/rickwicklin/" rel="author" target="_blank"&gt;Rick Wicklin&lt;/A&gt;&amp;nbsp;and I got the results of means of all variables. But, I still do not see any output file that contains the winsorized data. Can any one help plz.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="text"&gt;%let DSName = sashelp.heart;
proc iml;
/* SAS/IML module to Winsorize each column of a matrix. 
   Input proportion of observations to Winsorize: prop &amp;lt; 0.5. 
   Ex:  y = Winsorize(x, 0.1) computes the two-side 10% Winsorized data */
start Winsorize(x, prop);
   p = ncol(x);            /* number of columns */
   w = x;                  /* copy of x */
   do i = 1 to p;
      z = x[,i];           /* copy i_th column */
      n = countn(z);       /* count nonmissing values */
      k = ceil(prop*n);    /* number of obs to trim from each tail */
      r = rank(z);         /* rank values in i_th column */
      /* find target values and obs with smaller/larger values */
      lowIdx = loc(r&amp;lt;=k &amp;amp; r^=.);
      lowVal = z[loc(r=k+1)]; 
      highIdx = loc(r&amp;gt;=n-k+1);
      highVal = z[loc(r=n-k)]; 
      /* Winsorize (replace) k smallest and k largest values */
      w[lowIdx,i] = lowVal;
      w[highIdx,i] = highVal;
   end;
   return(w);
finish;
&amp;nbsp;
/* test the algorithm on numerical vars in a data set */
use &amp;amp;DSName;
read all var _NUM_ into X[colname=varNames];
close;
winX = Winsorize(X, 0.1);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 17:11:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Winsorized-output-file/m-p/529761#M144803</guid>
      <dc:creator>Almutairi</dc:creator>
      <dc:date>2019-01-24T17:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: Winsorized output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Winsorized-output-file/m-p/529763#M144805</link>
      <description>&lt;P&gt;I don't believe that code actually writes back to the data set. It defines a function to winsorize and shows how it can be used. You would need to add the code to save it back to a data set. &lt;BR /&gt;&lt;BR /&gt;However, this question was asked at least once if not twice this week, so a quick search within the time frame should get you some generic examples.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/winsoring-outliers/m-p/529770#M144807" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/winsoring-outliers/m-p/529770#M144807&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 17:36:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Winsorized-output-file/m-p/529763#M144805</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-24T17:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Winsorized output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Winsorized-output-file/m-p/530049#M144918</link>
      <description>&lt;P&gt;Check WANT table. P.S. since is a IML question, why not post it at IML forum , Rick is there ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let DSName = sashelp.heart;
proc iml;
/* SAS/IML module to Winsorize each column of a matrix. 
   Input proportion of observations to Winsorize: prop &amp;lt; 0.5. 
   Ex:  y = Winsorize(x, 0.1) computes the two-side 10% Winsorized data */
start Winsorize(x, prop);
   p = ncol(x);            /* number of columns */
   w = x;                  /* copy of x */
   do i = 1 to p;
      z = x[,i];           /* copy i_th column */
      n = countn(z);       /* count nonmissing values */
      k = ceil(prop*n);    /* number of obs to trim from each tail */
      r = rank(z);         /* rank values in i_th column */
      /* find target values and obs with smaller/larger values */
      lowIdx = loc(r&amp;lt;=k &amp;amp; r^=.);
      lowVal = z[loc(r=k+1)]; 
      highIdx = loc(r&amp;gt;=n-k+1);
      highVal = z[loc(r=n-k)]; 
      /* Winsorize (replace) k smallest and k largest values */
      w[lowIdx,i] = lowVal;
      w[highIdx,i] = highVal;
   end;
   return(w);
finish;
 
/* test the algorithm on numerical vars in a data set */
use &amp;amp;DSName;
read all var _NUM_ into X[colname=varNames];
close;
winX = Winsorize(X, 0.1);

create want from winX[c=varNames];
append from winX;
close;
quit;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Jan 2019 13:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Winsorized-output-file/m-p/530049#M144918</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-01-25T13:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Winsorized output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Winsorized-output-file/m-p/530051#M144920</link>
      <description>&lt;P&gt;And here is my code.&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);
  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>Fri, 25 Jan 2019 13:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Winsorized-output-file/m-p/530051#M144920</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-01-25T13:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Winsorized output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Winsorized-output-file/m-p/530092#M144937</link>
      <description>&lt;P&gt;Many thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 15:32:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Winsorized-output-file/m-p/530092#M144937</guid>
      <dc:creator>Almutairi</dc:creator>
      <dc:date>2019-01-25T15:32:03Z</dc:date>
    </item>
  </channel>
</rss>

