<?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: Return computation with PROC EXPAND in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Return-computation-with-PROC-EXPAND/m-p/516930#M73288</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=stocks;
	by stock date;
run;
proc expand data=stocks out=result(drop=time);
	by stock;
	 convert price=return / transformout=( ratio 1 -1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 29 Nov 2018 01:57:00 GMT</pubDate>
    <dc:creator>learsaas</dc:creator>
    <dc:date>2018-11-29T01:57:00Z</dc:date>
    <item>
      <title>Return computation with PROC EXPAND</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Return-computation-with-PROC-EXPAND/m-p/516925#M73287</link>
      <description>&lt;P&gt;I would like to calculate returns using PROC EXPAND. I could use just a simple DATA step but I would like to learn more about PROC EXPAND.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My dataset has 3 columns containing stock, date, and price. I could use the following DATA step:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data stocks;
    set stocks;
    by stock date ;
    return=price/lag(price)-1;
    if first.stock then return=.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But How do I do&amp;nbsp; this using PROC EXPAND? in particular, what do I put in the TRANSFORMIN&amp;nbsp;and TRANSFORMOUT ?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 00:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Return-computation-with-PROC-EXPAND/m-p/516925#M73287</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2018-11-29T00:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Return computation with PROC EXPAND</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Return-computation-with-PROC-EXPAND/m-p/516930#M73288</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=stocks;
	by stock date;
run;
proc expand data=stocks out=result(drop=time);
	by stock;
	 convert price=return / transformout=( ratio 1 -1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Nov 2018 01:57:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Return-computation-with-PROC-EXPAND/m-p/516930#M73288</guid>
      <dc:creator>learsaas</dc:creator>
      <dc:date>2018-11-29T01:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: Return computation with PROC EXPAND</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Return-computation-with-PROC-EXPAND/m-p/516934#M73290</link>
      <description>&lt;P&gt;Thanks. just to confirm if I understand the code correctly,&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;transformout&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt; ratio &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;-1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;means getting the ratio of the current value over lag 1 and then minus 1 to get the return right? So, say if I want to get returns between now and 4 periods ago, it should be:&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;transformout&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt; ratio 4 &lt;SPAN class="token number"&gt;-1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Am I correct?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 02:36:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Return-computation-with-PROC-EXPAND/m-p/516934#M73290</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2018-11-29T02:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Return computation with PROC EXPAND</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Return-computation-with-PROC-EXPAND/m-p/516936#M73292</link>
      <description>&lt;P&gt;well done&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 02:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Return-computation-with-PROC-EXPAND/m-p/516936#M73292</guid>
      <dc:creator>learsaas</dc:creator>
      <dc:date>2018-11-29T02:49:56Z</dc:date>
    </item>
  </channel>
</rss>

