<?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: Do loop (macro) in constructing annual buy and hold return using monthly returns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/636942#M189303</link>
    <description>&lt;P&gt;It is pretty clear: your work library does not have a data set named ANNUALBHR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check spelling of the name, or if the set is in a different library use the &amp;lt;lib&amp;gt;.datasetname syntax.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you created the data set in a previous SAS session then you likely need to recreate it as the Work library is cleared out at the end of a SAS session.&lt;/P&gt;</description>
    <pubDate>Thu, 02 Apr 2020 16:56:19 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-04-02T16:56:19Z</dc:date>
    <item>
      <title>Do loop (macro) in constructing annual buy and hold return using monthly returns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/636933#M189298</link>
      <description>&lt;P&gt;Dear Madam/Sir,&lt;/P&gt;&lt;P&gt;I try one example code to construct annual buy and hold return (returns for eleven months ahead of closing&amp;nbsp; month plus return in closing month) using monthly return.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will be grateful if anybody can advise me how to fix the following error in do loop. The data set is attached. Thank you. Joon1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data c4;&lt;BR /&gt;set c3;&lt;BR /&gt;by permno;&lt;BR /&gt;&lt;U&gt;if _n_=1 then do until (end_of_annualreturn);&lt;/U&gt;&lt;BR /&gt;&lt;U&gt;set annualbhr end=end_of_annualreturn;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;ERROR: File WORK.ANNUALBHR.DATA does not exist.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;array annualbhr {1990:2019,1:12} _temporary_ ;&lt;BR /&gt;array logplusone {12} _temporary_;&lt;BR /&gt;y=year(date);&lt;BR /&gt;m=month(date);&lt;BR /&gt;logplusone{m}=log(1+ret);&lt;BR /&gt;if closemonth^=.;&lt;BR /&gt;if n(of logplusone{*})=12 then annualbhr{y,m}=exp(sum(of logplusone{*}));&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 16:26:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/636933#M189298</guid>
      <dc:creator>joon1</dc:creator>
      <dc:date>2020-04-02T16:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop (macro) in constructing annual buy and hold return using monthly returns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/636942#M189303</link>
      <description>&lt;P&gt;It is pretty clear: your work library does not have a data set named ANNUALBHR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check spelling of the name, or if the set is in a different library use the &amp;lt;lib&amp;gt;.datasetname syntax.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you created the data set in a previous SAS session then you likely need to recreate it as the Work library is cleared out at the end of a SAS session.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 16:56:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/636942#M189303</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-02T16:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop (macro) in constructing annual buy and hold return using monthly returns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/637057#M189350</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thanks for your prompt&amp;nbsp;reply, ballardw. Annualbhr is not library name created in the previous step. It is the variable name that I want to construct as shown at the last line in the program.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;I am not familiar&amp;nbsp;with macro do-loop logic, so I posted this question in the forum.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am not asking the interpretation of error. My question was how to construct do loop from month 1 (-11 month) to month 12 (closing month).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;(1+ret)(1+ret)----(1+ret(closing month)-1=annualbhr&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Any help will be appreciated.&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;&lt;DIV&gt;Joon1&lt;/DIV&gt;</description>
      <pubDate>Thu, 02 Apr 2020 20:29:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/637057#M189350</guid>
      <dc:creator>joon1</dc:creator>
      <dc:date>2020-04-02T20:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop (macro) in constructing annual buy and hold return using monthly returns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/637123#M189392</link>
      <description>&lt;P&gt;Hi &lt;A class="trigger-hovercard" style="color: #007dc3;" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/107110" target="_blank"&gt;joon1,&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;When you write in your code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set annualbhr end=end_of_annualreturn;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS interprets that as you are reading data table named WORK.ANNUALBHR (&lt;A href="https://go.documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=p00hxg3x8lwivcn1f0e9axziw57y.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;statement SET&lt;/A&gt; is used for reading data tables). Since this data table does not exist you get that &lt;U&gt;ERROR: File WORK.ANNUALBHR.DATA does not exist.&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is nothing wrong with your array named annualbhr.&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 01:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/637123#M189392</guid>
      <dc:creator>LeonidBatkhan</dc:creator>
      <dc:date>2020-04-03T01:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop (macro) in constructing annual buy and hold return using monthly returns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/637124#M189393</link>
      <description>&lt;P&gt;Looks like you probably just need to read until you see the observation with CLOSEMONTH non-missing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  do n=1 by 1 until(not missing(closemonth));
     logplusone=log(1+ret);
     sumlogplusone=sum(0,sumlogplusone,logplusone);
  end;
  if n=12 then annualbhr =exp(sumlogplusone));
  drop rev;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Apr 2020 01:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/637124#M189393</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-03T01:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop (macro) in constructing annual buy and hold return using monthly returns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/637156#M189399</link>
      <description>&lt;P&gt;Thanks, Tom, for your suggesion.&lt;/P&gt;&lt;P&gt;However, your programming makes sas program running for a couple of hours without producing output. It seems that there is a indefinite loop in your code. What does "drop rev" indicate? Thanks, Joon1.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 03:43:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/637156#M189399</guid>
      <dc:creator>joon1</dc:creator>
      <dc:date>2020-04-03T03:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop (macro) in constructing annual buy and hold return using monthly returns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/637163#M189401</link>
      <description>&lt;P&gt;Thank you very much to all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code works well.&lt;/P&gt;&lt;P&gt;data c4;&lt;BR /&gt;set c3;&lt;BR /&gt;by permno;&lt;BR /&gt;do n=1 by 1 until(not missing(closemonth));&lt;BR /&gt;array logplusone {12} _temporary_;&lt;BR /&gt;y=year(date);&lt;BR /&gt;m=month(date);&lt;BR /&gt;logplusone{m}=log(1+ret);&lt;BR /&gt;if closemonth^=.;&lt;BR /&gt;if n(of logplusone{*})=12 then annualbhr=exp(sum(of logplusone{*}))-1;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 05:58:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-macro-in-constructing-annual-buy-and-hold-return-using/m-p/637163#M189401</guid>
      <dc:creator>joon1</dc:creator>
      <dc:date>2020-04-03T05:58:54Z</dc:date>
    </item>
  </channel>
</rss>

