<?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 reduce running time that works for a large dataset saved in a remote library in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/reduce-running-time-that-works-for-a-large-dataset-saved-in-a/m-p/116928#M24133</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to work on a large dataset in total of approximately 40TB. I can access to the datasets by connecting to a server that has all the datasets saved as sas dataset format. Here I am trying to find an efficient coding that reduces running time as much as possible. The only output I need is the group difference for a couple of variables such as 'count' and the group mean such as 'meanspread'&amp;nbsp; that I compute using proc means at the end of the attached code. In order to reduce the time, I tried to use 'rsubmit' and 'SAS Data Views'. However, it still takes way too long and any comment or feedback that helps to reduce the running time is truly appreciated at this moment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FYI, the name of the dataset in the remote library 'taq' is composed of two parts: cq_(or ct_) + date for the dataset, e.g., cq_19930102, cq_19930103,... :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname mydir 'C:\sasdata\taq';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let wrds=wrds.wharton.upenn.edu 4016;&lt;/P&gt;&lt;P&gt;options comamid=TCP remote=WRDS;&lt;/P&gt;&lt;P&gt;signon username=_prompt_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rsubmit;&lt;/P&gt;&lt;P&gt;libname taq '/wrds/taq/sasdata';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data quotes/view=quotes;&lt;/P&gt;&lt;P&gt;set taq.cq_: ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data trades/view=trades;&lt;/P&gt;&lt;P&gt;set taq.ct_: ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tradesquotes/view=tradesquotes;&lt;/P&gt;&lt;P&gt;set trades quotes ;&lt;/P&gt;&lt;P&gt;by symbol date time type;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tr_qt/view= tr_qt;&lt;/P&gt;&lt;P&gt;set tradesquotes;&lt;/P&gt;&lt;P&gt;lag_date=lag(date);&lt;/P&gt;&lt;P&gt;if date^=lag_date or symbol^=lag_symbol then do;&lt;/P&gt;&lt;P&gt;retain prior_qtime_adjusted;&lt;/P&gt;&lt;P&gt;if type='T' then output;&lt;/P&gt;&lt;P&gt;keep symbol date time price size prior_bid prior_ofr;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tr_qt2/view= tr_qt2;&lt;/P&gt;&lt;P&gt;set tr_qt;&lt;/P&gt;&lt;P&gt;lagprice1=lag(price);&lt;/P&gt;&lt;P&gt;mid=(prior_ofr+prior_bid)/2;&lt;/P&gt;&lt;P&gt;if price&amp;gt;mid then order=1;&lt;/P&gt;&lt;P&gt;else if price&amp;lt;mid then order=-1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means data=tr_qt2 noprint;&lt;/P&gt;&lt;P&gt;var size dollars;&lt;/P&gt;&lt;P&gt;class month order;&lt;/P&gt;&lt;P&gt;output out=output_raw n=count sum(size dollars)=sumsize sumdollars mean(spread)=meanspread;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data outputcut;&lt;/P&gt;&lt;P&gt;set output_raw;&lt;/P&gt;&lt;P&gt;where _type_=3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc transpose data=outputcut out=output_num;&lt;/P&gt;&lt;P&gt;by month;&lt;/P&gt;&lt;P&gt;var count;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=outputcut out=output_sh;&lt;/P&gt;&lt;P&gt;by month;&lt;/P&gt;&lt;P&gt;var sumsize;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tmp_OIBNUM(keep=month OIBNUM);&lt;/P&gt;&lt;P&gt;set output_num;&lt;/P&gt;&lt;P&gt;OIBNUM=COL3-COL1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tmp_OIBSH(keep=month OIBSH);&lt;/P&gt;&lt;P&gt;set output_sh;&lt;/P&gt;&lt;P&gt;OIBSH=COL3-COL1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tmp_LIQ (keep=month QSPR NUMTRANS VOL);&lt;/P&gt;&lt;P&gt;set output_raw;&lt;/P&gt;&lt;P&gt;where _type_=2;&lt;/P&gt;&lt;P&gt;QSPR=meanspread;&lt;/P&gt;&lt;P&gt;NUMTRANS=count;&lt;/P&gt;&lt;P&gt;VOL=sumdollars;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data finalout;&lt;/P&gt;&lt;P&gt;merge tmp_OIBNUM tmp_OIBSH tmp_LIQ;&lt;/P&gt;&lt;P&gt;by month;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc download data=finalout out=mydir.final;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=finalout (obs=100);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;endrsubmit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 06 Jan 2013 15:11:18 GMT</pubDate>
    <dc:creator>ibsulkim</dc:creator>
    <dc:date>2013-01-06T15:11:18Z</dc:date>
    <item>
      <title>reduce running time that works for a large dataset saved in a remote library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reduce-running-time-that-works-for-a-large-dataset-saved-in-a/m-p/116928#M24133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to work on a large dataset in total of approximately 40TB. I can access to the datasets by connecting to a server that has all the datasets saved as sas dataset format. Here I am trying to find an efficient coding that reduces running time as much as possible. The only output I need is the group difference for a couple of variables such as 'count' and the group mean such as 'meanspread'&amp;nbsp; that I compute using proc means at the end of the attached code. In order to reduce the time, I tried to use 'rsubmit' and 'SAS Data Views'. However, it still takes way too long and any comment or feedback that helps to reduce the running time is truly appreciated at this moment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FYI, the name of the dataset in the remote library 'taq' is composed of two parts: cq_(or ct_) + date for the dataset, e.g., cq_19930102, cq_19930103,... :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname mydir 'C:\sasdata\taq';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let wrds=wrds.wharton.upenn.edu 4016;&lt;/P&gt;&lt;P&gt;options comamid=TCP remote=WRDS;&lt;/P&gt;&lt;P&gt;signon username=_prompt_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rsubmit;&lt;/P&gt;&lt;P&gt;libname taq '/wrds/taq/sasdata';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data quotes/view=quotes;&lt;/P&gt;&lt;P&gt;set taq.cq_: ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data trades/view=trades;&lt;/P&gt;&lt;P&gt;set taq.ct_: ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tradesquotes/view=tradesquotes;&lt;/P&gt;&lt;P&gt;set trades quotes ;&lt;/P&gt;&lt;P&gt;by symbol date time type;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tr_qt/view= tr_qt;&lt;/P&gt;&lt;P&gt;set tradesquotes;&lt;/P&gt;&lt;P&gt;lag_date=lag(date);&lt;/P&gt;&lt;P&gt;if date^=lag_date or symbol^=lag_symbol then do;&lt;/P&gt;&lt;P&gt;retain prior_qtime_adjusted;&lt;/P&gt;&lt;P&gt;if type='T' then output;&lt;/P&gt;&lt;P&gt;keep symbol date time price size prior_bid prior_ofr;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tr_qt2/view= tr_qt2;&lt;/P&gt;&lt;P&gt;set tr_qt;&lt;/P&gt;&lt;P&gt;lagprice1=lag(price);&lt;/P&gt;&lt;P&gt;mid=(prior_ofr+prior_bid)/2;&lt;/P&gt;&lt;P&gt;if price&amp;gt;mid then order=1;&lt;/P&gt;&lt;P&gt;else if price&amp;lt;mid then order=-1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means data=tr_qt2 noprint;&lt;/P&gt;&lt;P&gt;var size dollars;&lt;/P&gt;&lt;P&gt;class month order;&lt;/P&gt;&lt;P&gt;output out=output_raw n=count sum(size dollars)=sumsize sumdollars mean(spread)=meanspread;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data outputcut;&lt;/P&gt;&lt;P&gt;set output_raw;&lt;/P&gt;&lt;P&gt;where _type_=3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc transpose data=outputcut out=output_num;&lt;/P&gt;&lt;P&gt;by month;&lt;/P&gt;&lt;P&gt;var count;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=outputcut out=output_sh;&lt;/P&gt;&lt;P&gt;by month;&lt;/P&gt;&lt;P&gt;var sumsize;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tmp_OIBNUM(keep=month OIBNUM);&lt;/P&gt;&lt;P&gt;set output_num;&lt;/P&gt;&lt;P&gt;OIBNUM=COL3-COL1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tmp_OIBSH(keep=month OIBSH);&lt;/P&gt;&lt;P&gt;set output_sh;&lt;/P&gt;&lt;P&gt;OIBSH=COL3-COL1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tmp_LIQ (keep=month QSPR NUMTRANS VOL);&lt;/P&gt;&lt;P&gt;set output_raw;&lt;/P&gt;&lt;P&gt;where _type_=2;&lt;/P&gt;&lt;P&gt;QSPR=meanspread;&lt;/P&gt;&lt;P&gt;NUMTRANS=count;&lt;/P&gt;&lt;P&gt;VOL=sumdollars;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data finalout;&lt;/P&gt;&lt;P&gt;merge tmp_OIBNUM tmp_OIBSH tmp_LIQ;&lt;/P&gt;&lt;P&gt;by month;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc download data=finalout out=mydir.final;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=finalout (obs=100);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;endrsubmit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Jan 2013 15:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reduce-running-time-that-works-for-a-large-dataset-saved-in-a/m-p/116928#M24133</guid>
      <dc:creator>ibsulkim</dc:creator>
      <dc:date>2013-01-06T15:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: reduce running time that works for a large dataset saved in a remote library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reduce-running-time-that-works-for-a-large-dataset-saved-in-a/m-p/116929#M24134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You must not have posted all of your code as the code you posted would have crashed because it contained a do loop without an end statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if using a view is actually going to help, but I'll leave that for others to comment on.&amp;nbsp; However, what I will comment on is the fact that you appear to be doing three, four or more unnecessary reads of the large datasets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you didn't include any sort statements can we presume that the data, as input, is already in the correct sort order?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hard to say without knowing the full code or having an example dataset, but it appears that everything leading up to your proc means could be replaced with one datastep .. something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tr_qt2 (keep=symbol date time price size&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prior_bid prior_ofrtr_qt2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lagprice1 mid order);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set taq.cq_:&amp;nbsp; taq.ct_: ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by symbol date time type;&lt;/P&gt;&lt;P&gt;&amp;nbsp; lag_date=lag(date);&lt;/P&gt;&lt;P&gt;/*&amp;nbsp; if date^=lag_date or symbol^=lag_symbol then do;*/&lt;/P&gt;&lt;P&gt;/*&amp;nbsp; ???? Do what?*/&lt;/P&gt;&lt;P&gt;/*&amp;nbsp; ???? end with an end; statement;*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; if type='T';&lt;/P&gt;&lt;P&gt;&amp;nbsp; lagprice1=lag(price);&lt;/P&gt;&lt;P&gt;&amp;nbsp; mid=(prior_ofr+prior_bid)/2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if price&amp;gt;mid then order=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else if price&amp;lt;mid then order=-1;&lt;/P&gt;&lt;P&gt;/* ????&amp;nbsp; what to do if price eq mid*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Jan 2013 16:16:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reduce-running-time-that-works-for-a-large-dataset-saved-in-a/m-p/116929#M24134</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-01-06T16:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: reduce running time that works for a large dataset saved in a remote library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reduce-running-time-that-works-for-a-large-dataset-saved-in-a/m-p/116930#M24135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To follow on to Art's comments, DATA VIEWs save on disk space at the expense of execution time, as every time the data are accessed the computations have to be redone.&amp;nbsp; Arts approach gets rid of the need for views altogether.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One caution on the use of lag(price).&amp;nbsp; As this is after a subsetting IF, you may or may not be getting the value you want.&amp;nbsp; This note from the LAG function documentation is pertinent:&amp;nbsp; "&lt;SPAN class="strong"&gt;Note:&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp; Storing values at the bottom of the queue and returning values from the top of the queue occurs only when the function is executed. An occurrence of the LAG&lt;SPAN class="emph"&gt;n&lt;/SPAN&gt; function that is executed conditionally will store and return values only from the observations for which the condition is satisfied."&amp;nbsp; [Art's program will give the same lag sequence that yours did, it's just a general caution.]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Doc Muhlbaier&lt;/P&gt;&lt;P&gt;Duke&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Jan 2013 15:05:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reduce-running-time-that-works-for-a-large-dataset-saved-in-a/m-p/116930#M24135</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2013-01-07T15:05:38Z</dc:date>
    </item>
  </channel>
</rss>

