<?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: Array Imputation with Aggregate in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-Imputation-with-Aggregate/m-p/282857#M57547</link>
    <description>&lt;P&gt;It can be done in a single data step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set sashelp.class;
if age = 13 then call missing(height, weight);
run;

data testi;
if 0 then set test;
array _x {*} _numeric_;
array _m {9999} _temporary_;
do while(not endmin);
    set test end=endmin;
    do i = 1 to dim(_x);
        _m{i} = min(_m{i}, _x{i});
        end;
    end;
do while(not endimp);
    set test end=endimp;
    do i = 1 to dim(_x);
        if missing(_x{i}) then _x{i} = _m{i};
        end;
    output;
    end;
drop i;
stop;
run;
    &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 08 Jul 2016 03:32:36 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-07-08T03:32:36Z</dc:date>
    <item>
      <title>Array Imputation with Aggregate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Imputation-with-Aggregate/m-p/282841#M57536</link>
      <description>&lt;P&gt;I love SAS for it's arrays. I use it often to make imputations like this: &amp;nbsp;(change missing to the value 75)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; set have;
   array change [*] x1-x999;
            do over change;
            	if change=. then change=75;
            end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But what if, instead of changing to 75, I wanted impute to the minimum value of x.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thinking about this hurts my brain because I know that array is moving "sideways" and I'm looking for a whole dataset aggregation to obtain the minimum.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm sure I could hack someting together, but I'm really worried about effiecency due to my dataset size.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2016 00:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Imputation-with-Aggregate/m-p/282841#M57536</guid>
      <dc:creator>JBerry</dc:creator>
      <dc:date>2016-07-08T00:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Array Imputation with Aggregate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Imputation-with-Aggregate/m-p/282844#M57539</link>
      <description>&lt;P&gt;Why not?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We can use the MINIMUM function with array.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since DO OVER is deprecated, I use the usual way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input x1 x2 x3 x4 x5;
datalines;
10 12 11  3 10
 3  7 10  .  5
14  . 20  1  3
;
run;


data want;
   set have;
   array change[*] x1-x5;
   do i = 1 to dim(change);
      min = min(of change[*]);
      if change[i] = . then change[i] = min;
   end;
keep x:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jul 2016 01:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Imputation-with-Aggregate/m-p/282844#M57539</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2016-07-08T01:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Array Imputation with Aggregate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Imputation-with-Aggregate/m-p/282847#M57540</link>
      <description>&lt;P&gt;I'm assuming your thinking of going column by column? Or is it min across all X, across all observations?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should take a look at Proc stdize with missing and replace options.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2016 02:20:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Imputation-with-Aggregate/m-p/282847#M57540</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-08T02:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: Array Imputation with Aggregate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Imputation-with-Aggregate/m-p/282857#M57547</link>
      <description>&lt;P&gt;It can be done in a single data step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set sashelp.class;
if age = 13 then call missing(height, weight);
run;

data testi;
if 0 then set test;
array _x {*} _numeric_;
array _m {9999} _temporary_;
do while(not endmin);
    set test end=endmin;
    do i = 1 to dim(_x);
        _m{i} = min(_m{i}, _x{i});
        end;
    end;
do while(not endimp);
    set test end=endimp;
    do i = 1 to dim(_x);
        if missing(_x{i}) then _x{i} = _m{i};
        end;
    output;
    end;
drop i;
stop;
run;
    &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jul 2016 03:32:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Imputation-with-Aggregate/m-p/282857#M57547</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-07-08T03:32:36Z</dc:date>
    </item>
  </channel>
</rss>

