<?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: SAS code is taking too long in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-code-is-taking-too-long/m-p/647262#M193687</link>
    <description>&lt;P&gt;Thanks! I have already handled the missing values.&lt;BR /&gt;data df1;&lt;BR /&gt;array ret{0:11} _temporary_;&lt;BR /&gt;set df;&lt;BR /&gt;by permno;&lt;BR /&gt;if first.permno then call missing(of ret{*});&lt;BR /&gt;ret{mod(_n_,12)} = monthly_ret;&lt;BR /&gt;std_dev = std(of ret{*});&lt;BR /&gt;run;&lt;BR /&gt;Any ideas why I´m getting this error : "The variable type of ret is invalid in this context"?&lt;/P&gt;</description>
    <pubDate>Tue, 12 May 2020 22:43:29 GMT</pubDate>
    <dc:creator>avecesar97</dc:creator>
    <dc:date>2020-05-12T22:43:29Z</dc:date>
    <item>
      <title>SAS code is taking too long</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-code-is-taking-too-long/m-p/647243#M193675</link>
      <description>&lt;P&gt;Hi guys, I am trying to compute rolling standard deviations using a&amp;nbsp; 12 month window&amp;nbsp; in sas but my&amp;nbsp; dataset is quite big( 4 million observations)&lt;/P&gt;&lt;PRE class="lang-r prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;    date    permno  return_stock    return_mkt&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;&lt;BR /&gt;01&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;/&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;01&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;/&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2000&lt;/SPAN&gt;  &lt;SPAN class="lit"&gt;10000&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;0.05&lt;/SPAN&gt;            &lt;SPAN class="lit"&gt;0.04&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;02&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;/&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;01&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;/&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2000&lt;/SPAN&gt;  &lt;SPAN class="lit"&gt;10000&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;0.06&lt;/SPAN&gt;            &lt;SPAN class="lit"&gt;0.03&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;03&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;/&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;01&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;/&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2000&lt;/SPAN&gt;  &lt;SPAN class="lit"&gt;10000&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;0.03&lt;/SPAN&gt;            &lt;SPAN class="lit"&gt;0.08&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;...&lt;/SPAN&gt;         
&lt;SPAN class="lit"&gt;01&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;/&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;01&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;/&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2005&lt;/SPAN&gt;  &lt;SPAN class="lit"&gt;10000&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;0.03&lt;/SPAN&gt;            &lt;SPAN class="lit"&gt;0.04&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;02&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;/&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;01&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;/&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2005&lt;/SPAN&gt;  &lt;SPAN class="lit"&gt;10000&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;0.06&lt;/SPAN&gt;            &lt;SPAN class="lit"&gt;0.03&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;03&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;/&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;01&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;/&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2005&lt;/SPAN&gt;  &lt;SPAN class="lit"&gt;10000&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;0.09&lt;/SPAN&gt;            &lt;SPAN class="lit"&gt;0.08&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;
create table df1 as select *,(select std(RET) from df where permno=a.permno &lt;BR /&gt;and date between intnx('month',a.date,-12) and a.date) as rolling_std_s from df as a; quit;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;I have been waiting for more than 4 hours and sas is apparently still trying to execute the task. I have also created subsamples by subsetting by date and then permno&amp;nbsp; but this doesn´t seem to work either. The code&amp;nbsp; works fine with 5-10 stocks. I would&amp;nbsp; appreciate some tips to fix this issue.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 21:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-code-is-taking-too-long/m-p/647243#M193675</guid>
      <dc:creator>avecesar97</dc:creator>
      <dc:date>2020-05-12T21:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code is taking too long</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-code-is-taking-too-long/m-p/647249#M193679</link>
      <description>&lt;P&gt;DELETED as per request.&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 17:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-code-is-taking-too-long/m-p/647249#M193679</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-05-13T17:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code is taking too long</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-code-is-taking-too-long/m-p/647253#M193681</link>
      <description>&lt;P&gt;A data step would be faster, but an intermediate solution would be to use a join.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The syntax you chose runs a query for every observation of the table.&lt;/P&gt;
&lt;P&gt;Like using the &lt;EM&gt;exists&lt;/EM&gt; operator, this syntax is best avoided, and replaced by a join.&lt;/P&gt;
&lt;P&gt;Running the 4 million queries you requested will take time of course.&lt;/P&gt;
&lt;P&gt;Especially if the data is not indexed, which is probably true since you didn't mention this fact.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A join will benefit most from sorting the source rather than indexing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 21:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-code-is-taking-too-long/m-p/647253#M193681</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-12T21:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code is taking too long</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-code-is-taking-too-long/m-p/647262#M193687</link>
      <description>&lt;P&gt;Thanks! I have already handled the missing values.&lt;BR /&gt;data df1;&lt;BR /&gt;array ret{0:11} _temporary_;&lt;BR /&gt;set df;&lt;BR /&gt;by permno;&lt;BR /&gt;if first.permno then call missing(of ret{*});&lt;BR /&gt;ret{mod(_n_,12)} = monthly_ret;&lt;BR /&gt;std_dev = std(of ret{*});&lt;BR /&gt;run;&lt;BR /&gt;Any ideas why I´m getting this error : "The variable type of ret is invalid in this context"?&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 22:43:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-code-is-taking-too-long/m-p/647262#M193687</guid>
      <dc:creator>avecesar97</dc:creator>
      <dc:date>2020-05-12T22:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code is taking too long</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-code-is-taking-too-long/m-p/647329#M193718</link>
      <description>&lt;P&gt;You will do best by posting an example of your input dataset, so we can create and test code for it.&lt;/P&gt;
&lt;P&gt;Post this example as a data step with datalines, and use the "little running man" icon to post the code.&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 06:58:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-code-is-taking-too-long/m-p/647329#M193718</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-13T06:58:01Z</dc:date>
    </item>
  </channel>
</rss>

