<?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: Proc expand missing values in moving average in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-missing-values-in-moving-average/m-p/776703#M247060</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you need the&lt;/P&gt;
&lt;P&gt;METHOD=NONE option&lt;/P&gt;
&lt;P&gt;on the PROC EXPAND statement to avoid any missing value interpolation to be done.&lt;/P&gt;
&lt;DIV class="xisDoc-refProc"&gt;
&lt;DIV id="etsug.expand.expprocstmt" class="aa-section"&gt;
&lt;DIV id="etsug_expand000472" class="aa-section"&gt;
&lt;DIV class="aa-options"&gt;
&lt;DL class="aa-options"&gt;
&lt;DD&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;The default is METHOD=SPLINE.&lt;/P&gt;
&lt;/DD&gt;
&lt;/DL&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Good luck,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
    <pubDate>Wed, 27 Oct 2021 11:09:40 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2021-10-27T11:09:40Z</dc:date>
    <item>
      <title>Proc expand missing values in moving average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-missing-values-in-moving-average/m-p/776690#M247056</link>
      <description>&lt;P&gt;I am trying to calculate a three month moving average of a variable that has missing value. If the selected time window contains missing values then they should be disregarded in the calculation. I tried doing this with the PROC EXPAND procedure, but it does not capture the missing values as expected. The documentation says that I should use the nomiss option but it has no effect on the results. The following code demonstrates the problem:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have(drop=i);
call streaminit(1);
do i = 1 to 15;
  period = i;
  x = round(rand('uniform')*10,1.);
  if 5 &amp;lt; period &amp;lt; 12 then x = .;
  output;
end;
run;&lt;BR /&gt;&lt;BR /&gt;proc expand data=have out=wrong_want(drop=time);&lt;BR /&gt;convert x=x_avg / transformout=(nomiss movave 3 );&lt;BR /&gt;run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The below PROC SQL block show what the results should be, however it is not feasible to you use it due to computational constrains from my side.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Proc sql;
create table want as
select a.period, a.x
      ,mean(b.x) as x_avg
from have as a
left join have as b
  on a.period -3 &amp;lt; b.period &amp;lt;= a.period
group by 1,2;
Quit;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 07:45:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-expand-missing-values-in-moving-average/m-p/776690#M247056</guid>
      <dc:creator>kashlik123</dc:creator>
      <dc:date>2021-10-27T07:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Proc expand missing values in moving average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-missing-values-in-moving-average/m-p/776703#M247060</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you need the&lt;/P&gt;
&lt;P&gt;METHOD=NONE option&lt;/P&gt;
&lt;P&gt;on the PROC EXPAND statement to avoid any missing value interpolation to be done.&lt;/P&gt;
&lt;DIV class="xisDoc-refProc"&gt;
&lt;DIV id="etsug.expand.expprocstmt" class="aa-section"&gt;
&lt;DIV id="etsug_expand000472" class="aa-section"&gt;
&lt;DIV class="aa-options"&gt;
&lt;DL class="aa-options"&gt;
&lt;DD&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;The default is METHOD=SPLINE.&lt;/P&gt;
&lt;/DD&gt;
&lt;/DL&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Good luck,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 11:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-expand-missing-values-in-moving-average/m-p/776703#M247060</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-10-27T11:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proc expand missing values in moving average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-missing-values-in-moving-average/m-p/776706#M247061</link>
      <description>&lt;P&gt;If you use the method=none option then proc expand will set any moving average that has missing values to missing as well. So for example if you have an MA window of 12 months and one of them has a missing value, then proc expand will set the MA value to null instead of calculating the average on the remaining 11 non-missing values.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 11:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-expand-missing-values-in-moving-average/m-p/776706#M247061</guid>
      <dc:creator>kashlik123</dc:creator>
      <dc:date>2021-10-27T11:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proc expand missing values in moving average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-missing-values-in-moving-average/m-p/776709#M247063</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;There may be a problem with your original example then (on page 1) as method=none results in PROC EXPAND giving exactly the same output as PROC SQL.&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 11:26:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-expand-missing-values-in-moving-average/m-p/776709#M247063</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-10-27T11:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc expand missing values in moving average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-missing-values-in-moving-average/m-p/776711#M247065</link>
      <description>&lt;P&gt;Do you mean the following:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc expand data=have out=wrong_want(drop=time);
convert x=x_avg / method=none transformout=(nomiss movave 3 );
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Because when I run this code it gives me a missing value for periods 6, 7, 12 and 13, whereas the proc sql doesn't.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 11:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-expand-missing-values-in-moving-average/m-p/776711#M247065</guid>
      <dc:creator>kashlik123</dc:creator>
      <dc:date>2021-10-27T11:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc expand missing values in moving average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-expand-missing-values-in-moving-average/m-p/776770#M247086</link>
      <description>&lt;P&gt;This code outputs the same data set as PROC SQL.&lt;/P&gt;
&lt;P&gt;Get rid of the nomiss option before movave.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc expand data=have out=wrong_want(drop=time) method=none;
convert x=x_avg / transformout = ( movave 3 );
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 15:20:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-expand-missing-values-in-moving-average/m-p/776770#M247086</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-10-27T15:20:49Z</dc:date>
    </item>
  </channel>
</rss>

