<?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 proc expand convert from day to month in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/429871#M68568</link>
    <description>&lt;P&gt;How can I convert daily returns&amp;nbsp; to monthly cumulative returns with proc expand convert?&lt;/P&gt;&lt;P&gt;Please note that some of the daily returns might be zero. Part of the data is attached.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jan 2018 03:37:56 GMT</pubDate>
    <dc:creator>vickyCh</dc:creator>
    <dc:date>2018-01-23T03:37:56Z</dc:date>
    <item>
      <title>proc expand convert from day to month</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/429871#M68568</link>
      <description>&lt;P&gt;How can I convert daily returns&amp;nbsp; to monthly cumulative returns with proc expand convert?&lt;/P&gt;&lt;P&gt;Please note that some of the daily returns might be zero. Part of the data is attached.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 03:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/429871#M68568</guid>
      <dc:creator>vickyCh</dc:creator>
      <dc:date>2018-01-23T03:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: proc expand convert from day to month</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/429873#M68569</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;P&gt;How can I convert daily returns&amp;nbsp; to monthly cumulative returns with proc expand convert?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How are you defining monthly cumulative returns?&lt;/P&gt;
&lt;P&gt;Something like the following may be what you're looking for. If you have 0's that should be fine mathematically but if you have missing dates that may cause issues. If the 0's don't make sense from a business perspective that's a different issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc expand data=sample out=want from=day to=month;
by entity;
id date;
convert return / observed=total;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/185804"&gt;@vickyCh&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;How can I convert daily returns&amp;nbsp; to monthly cumulative returns with proc expand convert?&lt;/P&gt;
&lt;P&gt;Please note that some of the daily returns might be zero. Part of the data is attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 03:54:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/429873#M68569</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-23T03:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: proc expand convert from day to month</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/429880#M68570</link>
      <description>&lt;P&gt;cumulative return=(1+r1)(1+r2)…(1+rn)-1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I tried to do was the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import&lt;/P&gt;&lt;P&gt;datafile="C:\temp\sample.xlsx"&lt;/P&gt;&lt;P&gt;dbms=xlsx&lt;/P&gt;&lt;P&gt;out=work.sample&lt;/P&gt;&lt;P&gt;replace;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc expand data=sample out=want method=none from=day to=month;&lt;BR /&gt;by entity;&lt;BR /&gt;id date;&lt;BR /&gt;convert ret = cum_return / transformin=(+1) transformout=(movprod n-1);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However the&amp;nbsp;&lt;SPAN&gt;number of periods,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=" AAmathtext"&gt;n, for each month might be different.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=" AAmathtext"&gt;That was the point confused me.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 04:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/429880#M68570</guid>
      <dc:creator>vickyCh</dc:creator>
      <dc:date>2018-01-23T04:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: proc expand convert from day to month</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/429882#M68571</link>
      <description>&lt;P&gt;Why not CUPROD?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that doesn't work, perhaps a data step is easier.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you include some expected data so that we can ensure the output is what you need?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 04:39:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/429882#M68571</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-23T04:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: proc expand convert from day to month</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/429891#M68572</link>
      <description>&lt;P&gt;For example, the&amp;nbsp;cumulative returns for 2000/1/31,2000/2/29 and&amp;nbsp;2000/3/31 are&amp;nbsp;&amp;nbsp;0.108340502,&amp;nbsp; -0.04989111 and&amp;nbsp;&amp;nbsp; 0.091433277 respectively for entity 1079.&lt;/P&gt;&lt;P&gt;DATE&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Ret&amp;nbsp; &amp;nbsp; &amp;nbsp; entity&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cumulative return&lt;BR /&gt;2000/1/3 0.026655203 1079&lt;BR /&gt;2000/1/4 -0.040201005 1079&lt;BR /&gt;2000/1/5 0 1079&lt;BR /&gt;2000/1/6 -0.0008726 1079&lt;BR /&gt;2000/1/7 0.045414846 1079&lt;BR /&gt;2000/1/10 0.009189641 1079&lt;BR /&gt;2000/1/11 -0.033940397 1079&lt;BR /&gt;2000/1/12 0.047129393 1079&lt;BR /&gt;2000/1/13 0 1079&lt;BR /&gt;2000/1/14 0.07692308 1079&lt;BR /&gt;2000/1/18 0.009118541 1079&lt;BR /&gt;2000/1/19 -0.018072288 1079&lt;BR /&gt;2000/1/20 0.009202454 1079&lt;BR /&gt;2000/1/21 -0.003799392 1079&lt;BR /&gt;2000/1/24 -0.025934402 1079&lt;BR /&gt;2000/1/25 -0.02349256 1079&lt;BR /&gt;2000/1/26 0.008019246 1079&lt;BR /&gt;2000/1/27 0.0548926 1079&lt;BR /&gt;2000/1/28 -0.046757165 1079&lt;BR /&gt;2000/1/31 0.019778481 1079&amp;nbsp; &amp;nbsp; &amp;nbsp; 0.108340502&lt;BR /&gt;2000/2/1 0.058184639 1079&lt;BR /&gt;2000/2/2 -0.045454547 1079&lt;BR /&gt;2000/2/3 0.006144393 1079&lt;BR /&gt;2000/2/4 0.00610687 1079&lt;BR /&gt;2000/2/7 -0.023520486 1079&lt;BR /&gt;2000/2/8 -0.012432013 1079&lt;BR /&gt;2000/2/9 0.002360346 1079&lt;BR /&gt;2000/2/10 -0.028436018 1079&lt;BR /&gt;2000/2/11 -0.038211383 1079&lt;BR /&gt;2000/2/14 0.014370245 1079&lt;BR /&gt;2000/2/15 -0.0125 1079&lt;BR /&gt;2000/2/16 0.009282701 1079&lt;BR /&gt;2000/2/17 -0.008361204 1079&lt;BR /&gt;2000/2/18 -0.005059022 1079&lt;BR /&gt;2000/2/22 -0.001694915 1079&lt;BR /&gt;2000/2/23 -0.008488964 1079&lt;BR /&gt;2000/2/24 0.030821918 1079&lt;BR /&gt;2000/2/25 0.024086379 1079&lt;BR /&gt;2000/2/28 0.0081103 1079&lt;BR /&gt;2000/2/29 -0.020917136 1079&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-0.04989111&lt;BR /&gt;2000/3/1 -0.023829088 1079&lt;BR /&gt;2000/3/2 -0.004208754 1079&lt;BR /&gt;2000/3/3 0.026204566 1079&lt;BR /&gt;2000/3/6 0.005766063 1079&lt;BR /&gt;2000/3/7 -0.022932023 1079&lt;BR /&gt;2000/3/8 0.015926236 1079&lt;BR /&gt;2000/3/9 0.023927392 1079&lt;BR /&gt;2000/3/10 0.003223207 1079&lt;BR /&gt;2000/3/13 0 1079&lt;BR /&gt;2000/3/14 -0.022489959 1079&lt;BR /&gt;2000/3/15 0.036154479 1079&lt;BR /&gt;2000/3/16 0.062648691 1079&lt;BR /&gt;2000/3/17 -0.043283582 1079&lt;BR /&gt;2000/3/20 0.010920437 1079&lt;BR /&gt;2000/3/21 -0.010030864 1079&lt;BR /&gt;2000/3/22 0.01948558 1079&lt;BR /&gt;2000/3/23 0.064220183 1079&lt;BR /&gt;2000/3/24 -0.01867816 1079&lt;BR /&gt;2000/3/27 -0.004392386 1079&lt;BR /&gt;2000/3/28 -0.0125 1079&lt;BR /&gt;2000/3/29 -0.034996279 1079&lt;BR /&gt;2000/3/30 0.010802469 1079&lt;BR /&gt;2000/3/31 0.011450382 1079&amp;nbsp; &amp;nbsp; 0.091433277&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 05:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/429891#M68572</guid>
      <dc:creator>vickyCh</dc:creator>
      <dc:date>2018-01-23T05:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: proc expand convert from day to month</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/429982#M68576</link>
      <description>&lt;P&gt;It is very easy for IML.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input DATE : yymmdd10.           Ret      entity ;
yymm=100*year(date)+month(date);
format date yymmdd10.;
cards;
2000/1/3 0.026655203 1079
2000/1/4 -0.040201005 1079
2000/1/5 0 1079
2000/1/6 -0.0008726 1079
2000/1/7 0.045414846 1079
2000/1/10 0.009189641 1079
2000/1/11 -0.033940397 1079
2000/1/12 0.047129393 1079
2000/1/13 0 1079
2000/1/14 0.07692308 1079
2000/1/18 0.009118541 1079
2000/1/19 -0.018072288 1079
2000/1/20 0.009202454 1079
2000/1/21 -0.003799392 1079
2000/1/24 -0.025934402 1079
2000/1/25 -0.02349256 1079
2000/1/26 0.008019246 1079
2000/1/27 0.0548926 1079
2000/1/28 -0.046757165 1079
2000/1/31 0.019778481 1079     
2000/2/1 0.058184639 1079
2000/2/2 -0.045454547 1079
2000/2/3 0.006144393 1079
2000/2/4 0.00610687 1079
2000/2/7 -0.023520486 1079
2000/2/8 -0.012432013 1079
2000/2/9 0.002360346 1079
2000/2/10 -0.028436018 1079
2000/2/11 -0.038211383 1079
2000/2/14 0.014370245 1079
2000/2/15 -0.0125 1079
2000/2/16 0.009282701 1079
2000/2/17 -0.008361204 1079
2000/2/18 -0.005059022 1079
2000/2/22 -0.001694915 1079
2000/2/23 -0.008488964 1079
2000/2/24 0.030821918 1079
2000/2/25 0.024086379 1079
2000/2/28 0.0081103 1079
2000/2/29 -0.020917136 1079    
2000/3/1 -0.023829088 1079
2000/3/2 -0.004208754 1079
2000/3/3 0.026204566 1079
2000/3/6 0.005766063 1079
2000/3/7 -0.022932023 1079
2000/3/8 0.015926236 1079
2000/3/9 0.023927392 1079
2000/3/10 0.003223207 1079
2000/3/13 0 1079
2000/3/14 -0.022489959 1079
2000/3/15 0.036154479 1079
2000/3/16 0.062648691 1079
2000/3/17 -0.043283582 1079
2000/3/20 0.010920437 1079
2000/3/21 -0.010030864 1079
2000/3/22 0.01948558 1079
2000/3/23 0.064220183 1079
2000/3/24 -0.01867816 1079
2000/3/27 -0.004392386 1079
2000/3/28 -0.0125 1079
2000/3/29 -0.034996279 1079
2000/3/30 0.010802469 1079
2000/3/31 0.011450382 1079
;
run;
proc iml;
use have;
read all var{yymm ret};
close;
levels=t(unique(yymm));
cum_ret= j(nrow(levels),1);
do i=1 to nrow(levels);
  idx=loc(yymm=levels[i]);
  cum_ret[i]=cuprod(ret[idx]+1)[ncol(idx)]-1;
end;

create want var{levels cum_ret};
append;
close;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jan 2018 13:42:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/429982#M68576</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-01-23T13:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: proc expand convert from day to month</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/430058#M68582</link>
      <description>&lt;P&gt;I know nothing about proc iml.&lt;/P&gt;&lt;P&gt;In addition to&amp;nbsp;cum_ret, could I keep the last row of each month of data (data=have) as well?&lt;/P&gt;&lt;P&gt;Meanwhile, there are many different entities to be considered.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 06:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/430058#M68582</guid>
      <dc:creator>vickyCh</dc:creator>
      <dc:date>2018-01-24T06:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: proc expand convert from day to month</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/430084#M68585</link>
      <description>&lt;P&gt;I get a different cumulative sum then you do for March, but is the following what you are trying to get?:&lt;/P&gt;
&lt;PRE&gt;data need;
  set have;
  yymm=100*year(date)+month(date);
run;

data want;
  set need;
  by entity yymm;
  retain cumret;
  amt=1+ret;
  if first.yymm then cumret=amt;
  else cumret=cumret*amt;
  if last.yymm then do;
    cumret=cumret-1;
    output;
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 17:14:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/430084#M68585</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-01-23T17:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: proc expand convert from day to month</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/430296#M68599</link>
      <description>&lt;P&gt;Thank you for your reply, Art. Your answers are correct. (Mine for March was a typo.)&lt;BR /&gt;The ends justify the means. Although your coding was not the same as what was on my mind, the results were what&amp;nbsp;I wanted.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 06:13:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/430296#M68599</guid>
      <dc:creator>vickyCh</dc:creator>
      <dc:date>2018-01-24T06:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: proc expand convert from day to month</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/430378#M68601</link>
      <description>I think Art gave what you need.But be careful. if ret have some missing value Art 's code would not work.</description>
      <pubDate>Wed, 24 Jan 2018 12:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/430378#M68601</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-01-24T12:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: proc expand convert from day to month</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/430394#M68602</link>
      <description>&lt;P&gt;As a matter of fact, I would very much like to know&amp;nbsp;how you cope with the question I asked with Proc IML.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 12:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/430394#M68602</guid>
      <dc:creator>vickyCh</dc:creator>
      <dc:date>2018-01-24T12:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: proc expand convert from day to month</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/430401#M68605</link>
      <description>&lt;P&gt;IML is broadly used in Finance or Security field , and IML have build-in function CUPROD() which is just for your question ,So let me connect to IML quickly . But for your scenario , data step is good enough .&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 13:11:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/430401#M68605</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-01-24T13:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: proc expand convert from day to month</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/430441#M68612</link>
      <description>&lt;P&gt;Many thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 14:27:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-expand-convert-from-day-to-month/m-p/430441#M68612</guid>
      <dc:creator>vickyCh</dc:creator>
      <dc:date>2018-01-24T14:27:10Z</dc:date>
    </item>
  </channel>
</rss>

