<?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 - Convert statement in SAS Forecasting and Econometrics</title>
    <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Proc-Expand-Convert-statement/m-p/336706#M2168</link>
    <description>&lt;P&gt;Makes sense, thanks Udo &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Feb 2017 20:27:55 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-02-28T20:27:55Z</dc:date>
    <item>
      <title>Proc Expand - Convert statement</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Proc-Expand-Convert-statement/m-p/336394#M2163</link>
      <description>&lt;P&gt;I'm trying to understand how PROC EXPAND works and why one calculation isn't working the way I expect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't understand why the third one doesn't work the way as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first two calculations are correct, but LEAD doesn't generate the data expected.&lt;/P&gt;
&lt;P&gt;From this original discussion:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://stackoverflow.com/q/42395126/1919583" target="_blank"&gt;http://stackoverflow.com/q/42395126/1919583&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*create sample data to work with;
data random;
    call streaminit(25);

    do date='01Jan2016'd to '31Dec2016'd;
        x=round(Rand('normal', 100, 15), 0.01);
        output;
        format date date9.;
    end;
run;

*Modified calculation;
proc expand data=random out=want;
    id date;
    convert x= x_movSum /transformout = (movsum 10 trimleft 9); /*This is the correct calculation expected*/
    convert x = x_movSumFIRST / transformout = (reverse movsum 10 trimleft 9 reverse);
    convert x = x_movSumWRONG /transformout = (lead 10 reverse movesum 10 reverse); /*suggest via Tom*/
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Feb 2017 00:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Proc-Expand-Convert-statement/m-p/336394#M2163</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-28T00:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Expand - Convert statement</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Proc-Expand-Convert-statement/m-p/336687#M2167</link>
      <description>&lt;P&gt;Hello -&lt;/P&gt;
&lt;P&gt;If I understand your question correctly you are mostly wondering about the effect of "lead 10", correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;expand&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;random out&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;want&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token procnames"&gt;convert&lt;/SPAN&gt; x &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; x_movSumWRONG &lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;transformout &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;lead &lt;SPAN class="token number"&gt;10&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;reverse&lt;/SPAN&gt; movesum &lt;SPAN class="token number"&gt;10&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;reverse&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;SPAN class="token comment"&gt;/*suggest via Tom*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Your data (random) looks like this - leaving out some data in the middle:&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE width="132"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;&lt;STRONG&gt;date&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="64"&gt;&lt;STRONG&gt;x&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;1-Jan-16&lt;/TD&gt;
&lt;TD width="64"&gt;114.68&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;2-Jan-16&lt;/TD&gt;
&lt;TD width="64"&gt;83.68&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;3-Jan-16&lt;/TD&gt;
&lt;TD width="64"&gt;111.5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;4-Jan-16&lt;/TD&gt;
&lt;TD width="64"&gt;86.82&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;5-Jan-16&lt;/TD&gt;
&lt;TD width="64"&gt;103.46&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;6-Jan-16&lt;/TD&gt;
&lt;TD width="64"&gt;92.85&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;7-Jan-16&lt;/TD&gt;
&lt;TD width="64"&gt;88.22&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;8-Jan-16&lt;/TD&gt;
&lt;TD width="64"&gt;98.48&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;9-Jan-16&lt;/TD&gt;
&lt;TD width="64"&gt;99.5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;10-Jan-16&lt;/TD&gt;
&lt;TD width="64"&gt;132.27&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;11-Jan-16&lt;/TD&gt;
&lt;TD width="64"&gt;87.05&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;12-Jan-16&lt;/TD&gt;
&lt;TD width="64"&gt;99.98&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;13-Jan-16&lt;/TD&gt;
&lt;TD width="64"&gt;75.69&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;…&lt;/TD&gt;
&lt;TD width="64"&gt;…&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;20-Dec-16&lt;/TD&gt;
&lt;TD width="64"&gt;93.67&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;21-Dec-16&lt;/TD&gt;
&lt;TD width="64"&gt;114.5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;22-Dec-16&lt;/TD&gt;
&lt;TD width="64"&gt;94.1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;23-Dec-16&lt;/TD&gt;
&lt;TD width="64"&gt;96.01&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;24-Dec-16&lt;/TD&gt;
&lt;TD width="64"&gt;104.5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;25-Dec-16&lt;/TD&gt;
&lt;TD width="64"&gt;104.69&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;26-Dec-16&lt;/TD&gt;
&lt;TD width="64"&gt;116.58&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;27-Dec-16&lt;/TD&gt;
&lt;TD width="64"&gt;98.41&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;28-Dec-16&lt;/TD&gt;
&lt;TD width="64"&gt;103.41&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;29-Dec-16&lt;/TD&gt;
&lt;TD width="64"&gt;110.42&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;30-Dec-16&lt;/TD&gt;
&lt;TD width="64"&gt;90.44&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;31-Dec-16&lt;/TD&gt;
&lt;TD width="64"&gt;88.62&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN class="token punctuation"&gt;Lead 10 will tell EXPAND to forget about the first 10 observations (obs)&amp;nbsp;- so your time series now starts at&amp;nbsp;87.05 - you will introduce missing values are the end of your series (unless you would add SETMISS 0, which would append 0s instead).&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class="token punctuation"&gt;Reverse will tell EXPAND to reverse the order,&amp;nbsp;the missing values you introduced&amp;nbsp;will be your new first obs,&amp;nbsp;87.05 your new last&amp;nbsp;obs.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class="token punctuation"&gt;Movesum 10 will create the backward moving sum&amp;nbsp;of 10 obs.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class="token punctuation"&gt;Finally Reserve will put the series into its original order again.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;If you decompose your "wrong" statement into:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;proc expand data=random out=want;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; id date;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; convert x = x_lead10 /transformout = (lead 10); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;convert x = x_reverse /transformout = (lead 10 reverse); &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;convert x = x_movsum10 /transformout = (lead 10 reverse movsum 10); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; convert x = x_reverseII /transformout = (lead 10 reverse movsum 10 reverse);&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;you will see these columns in WANT. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;IMG title="snapshot.JPG" alt="snapshot.JPG" src="https://communities.sas.com/t5/image/serverpage/image-id/7493iBB0E4C0E5E0DC331/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;In my mind this is the expected behaviour - it is just not the same what you'd like to archive with:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&amp;nbsp;convert x= x_movSum /transformout = (movsum 10 trimleft 9);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Hope this makes sense,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Udo&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 21:18:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Proc-Expand-Convert-statement/m-p/336687#M2167</guid>
      <dc:creator>udo_sas</dc:creator>
      <dc:date>2017-02-28T21:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Expand - Convert statement</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Proc-Expand-Convert-statement/m-p/336706#M2168</link>
      <description>&lt;P&gt;Makes sense, thanks Udo &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 20:27:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Proc-Expand-Convert-statement/m-p/336706#M2168</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-28T20:27:55Z</dc:date>
    </item>
  </channel>
</rss>

