<?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: Annual buy and hold return using monthly return files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Annual-buy-and-hold-return-using-monthly-return-files/m-p/636438#M189090</link>
    <description>&lt;P&gt;In the line&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if n(of logplusone{*})=12 then annualbhr=exp(sum(of logplusone{*}));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you are using annualbhr as variable, but it is an array, so you have to change it to something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if n(of logplusone{*})=12 then annualbhr{y,m}=exp(sum(of logplusone{*}));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 01 Apr 2020 05:18:31 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2020-04-01T05:18:31Z</dc:date>
    <item>
      <title>Annual buy and hold return using monthly return files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Annual-buy-and-hold-return-using-monthly-return-files/m-p/636067#M188900</link>
      <description>&lt;P&gt;Dear Madam/Sir,&lt;/P&gt;&lt;P&gt;I would like to construct annual buy and hold returns in each fiscal year (eleven month ahead of closemonth and closemonth) using monthly return files and try an example code in this forum.&lt;/P&gt;&lt;P&gt;I see the following error message. Any help will be highly appreciated.&amp;nbsp; Thanks. Joon1.&lt;/P&gt;&lt;P&gt;data c4;&lt;BR /&gt;set c3;&lt;BR /&gt;&amp;nbsp;by permno;&lt;BR /&gt;&amp;nbsp;if _n_=1 then do until;&lt;BR /&gt;&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: (, =.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;array {1979:2019,1:12} _temporary_ ;&lt;BR /&gt;ERROR: Undeclared array referenced: array.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: &amp;lt;, &amp;lt;=, =, &amp;gt;, &amp;gt;=, EQ, GE, GT, LE, LT,&lt;BR /&gt;NE, NG, NL, ^=, ~=.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;array logplusone {12} _temporary_;&lt;BR /&gt;&amp;nbsp;y=year(date);&lt;BR /&gt;&amp;nbsp;m=month(date);&lt;BR /&gt;&amp;nbsp;logplusone{m}=log(1+ret);&lt;BR /&gt;&amp;nbsp;if closemonth^=.;&lt;BR /&gt;&amp;nbsp;if n(of logplusone{*})=12 then annualbhr=exp(sum(of logplusone{*}));&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.C4 may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 34 variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data form is below.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;10001&lt;/TD&gt;&lt;TD&gt;19900131&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;-0.0185&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;10001&lt;/TD&gt;&lt;TD&gt;19900228&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;-0.0063&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;10001&lt;/TD&gt;&lt;TD&gt;19900330&lt;/TD&gt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gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;10001&lt;/TD&gt;&lt;TD&gt;19901130&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;10001&lt;/TD&gt;&lt;TD&gt;19901231&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;0.0013&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;permno&lt;/TD&gt;&lt;TD&gt;date&lt;/TD&gt;&lt;TD&gt;closemonth&lt;/TD&gt;&lt;TD&gt;ret&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 31 Mar 2020 03:32:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Annual-buy-and-hold-return-using-monthly-return-files/m-p/636067#M188900</guid>
      <dc:creator>joon1</dc:creator>
      <dc:date>2020-03-31T03:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: Annual buy and hold return using monthly return files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Annual-buy-and-hold-return-using-monthly-return-files/m-p/636075#M188902</link>
      <description>&lt;P&gt;The problem may be caused by skipping the condition in the until-statement in&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; if _n_=1 then do until;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Try something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if _n_ = 1 then do;
  do until (INSERT_CONDITION);
    ...
  end;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To increase the readability of you post, please use "insert SAS code" (the running man icon) and "insert code" for logs. Posting data in usable form is highly recommended if you want/expect tested code in answers.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 04:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Annual-buy-and-hold-return-using-monthly-return-files/m-p/636075#M188902</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-03-31T04:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: Annual buy and hold return using monthly return files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Annual-buy-and-hold-return-using-monthly-return-files/m-p/636288#M189013</link>
      <description>&lt;P&gt;Thank you for your reply, Andreas.&lt;/P&gt;&lt;P&gt;I used the following code and test data is attached (csv file).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data c4;&lt;BR /&gt;set c3;&lt;BR /&gt;by permno;&lt;BR /&gt;if _n_=1 then do until (end_of_annualbhr);&lt;BR /&gt;set ret end=end_of_annualbhr;&lt;BR /&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=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;And I had the following error message.&lt;/P&gt;&lt;P&gt;241 data c4;&lt;BR /&gt;242 set c3;&lt;BR /&gt;243 by permno;&lt;BR /&gt;244 if _n_=1 then do until (end_of_annualbhr);&lt;BR /&gt;245 set ret end=end_of_annualbhr;&lt;BR /&gt;ERROR: File WORK.RET.DATA does not exist.&lt;BR /&gt;246 array annualbhr {1990:2019,1:12} _temporary_ ;&lt;BR /&gt;247 array logplusone {12} _temporary_;&lt;BR /&gt;248 y=year(date);&lt;BR /&gt;249 m=month(date);&lt;BR /&gt;250 logplusone{m}=log(1+ret);&lt;BR /&gt;251 if closemonth^=.;&lt;BR /&gt;252 if n(of logplusone{*})=12 then annualbhr=exp(sum(of logplusone{*}));&lt;BR /&gt;ERROR: Illegal reference to the array annualbhr.&lt;BR /&gt;253 end;&lt;BR /&gt;254 run;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.C4 may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 33 variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help will be highly appreciated.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;Joon1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 16:29:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Annual-buy-and-hold-return-using-monthly-return-files/m-p/636288#M189013</guid>
      <dc:creator>joon1</dc:creator>
      <dc:date>2020-03-31T16:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Annual buy and hold return using monthly return files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Annual-buy-and-hold-return-using-monthly-return-files/m-p/636438#M189090</link>
      <description>&lt;P&gt;In the line&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if n(of logplusone{*})=12 then annualbhr=exp(sum(of logplusone{*}));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you are using annualbhr as variable, but it is an array, so you have to change it to something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if n(of logplusone{*})=12 then annualbhr{y,m}=exp(sum(of logplusone{*}));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Apr 2020 05:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Annual-buy-and-hold-return-using-monthly-return-files/m-p/636438#M189090</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-04-01T05:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Annual buy and hold return using monthly return files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Annual-buy-and-hold-return-using-monthly-return-files/m-p/636617#M189148</link>
      <description>&lt;P&gt;Thanks for your help. I tried the following code and still have an error message. It will be appreciative if you can advise me how to make do loop in the first two lines of the program. Thanks.&lt;/P&gt;&lt;P&gt;data c4;&lt;BR /&gt;set c3;&lt;BR /&gt;by permno;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;if _n_=1 then do until (end_of_annualreturn);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;set annualreturn end=end_of_annualreturn;&lt;/FONT&gt;&lt;BR /&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;&lt;U&gt;error message&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;435 data c4;&lt;BR /&gt;436 set c3;&lt;BR /&gt;437 by permno;&lt;BR /&gt;438 if _n_=1 then do until (end_of_annualreturn);&lt;BR /&gt;439 set annualreturn end=end_of_annualreturn;&lt;BR /&gt;ERROR: File WORK.ANNUALRETURN.DATA does not exist.&lt;BR /&gt;440 array annualbhr {1990:2019,1:12} _temporary_ ;&lt;BR /&gt;441 array logplusone {12} _temporary_;&lt;BR /&gt;442 y=year(date);&lt;BR /&gt;443 m=month(date);&lt;BR /&gt;444 logplusone{m}=log(1+ret);&lt;BR /&gt;445 if closemonth^=.;&lt;BR /&gt;446 if n(of logplusone{*})=12 then annualbhr{y,m}=exp(sum(of logplusone{*}));&lt;BR /&gt;447 end;&lt;BR /&gt;448 run;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.C4 may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 33 variables.&lt;BR /&gt;WARNING: Data set WORK.C4 was not replaced because this step was stopped.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2020 17:58:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Annual-buy-and-hold-return-using-monthly-return-files/m-p/636617#M189148</guid>
      <dc:creator>joon1</dc:creator>
      <dc:date>2020-04-01T17:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: Annual buy and hold return using monthly return files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Annual-buy-and-hold-return-using-monthly-return-files/m-p/636772#M189224</link>
      <description>&lt;P&gt;Please post logs using the "insert code" button and code using the "insert sas code" button, won't debug unformatted code. But the error-message you get is quite easy to understand: ERROR: File WORK.ANNUALRETURN.DATA does not exist.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 06:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Annual-buy-and-hold-return-using-monthly-return-files/m-p/636772#M189224</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-04-02T06:04:38Z</dc:date>
    </item>
  </channel>
</rss>

