<?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: ERROR: File XXXX is sequential. This task requires reading observations in a random order, but t in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-This-task-requires-reading-obs-in-random-order-but-engine/m-p/727241#M226142</link>
    <description>&lt;P&gt;AFAIK, hash solutions will only work with SAS datasets. The MODIFY statement can be used with caution against RDBMSs as demonstrated in this interesting paper:&amp;nbsp;&lt;A href="https://www.lexjansen.com/pnwsug/2008/CurtisMack-Modify.pdf" target="_blank"&gt;https://www.lexjansen.com/pnwsug/2008/CurtisMack-Modify.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Mar 2021 20:45:33 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2021-03-17T20:45:33Z</dc:date>
    <item>
      <title>ERROR:This task requires reading obs in random order, but engine allows only sequential access</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-This-task-requires-reading-obs-in-random-order-but-engine/m-p/727225#M226131</link>
      <description>&lt;P&gt;I am trying to update an oracle table.&lt;/P&gt;&lt;P&gt;I encounter this error when running the following data step:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data oracle.have(drop=_:);
    modify oracle.have end=last;
    if _n_=1 then do;
        declare hash h1(dataset:'update');
        declare hiter hh1('h1');
        _rc = h1.defineKey('id','tid','valid_to');
        _rc = h1.defineData('valid_from');
        _rc = h1.defineDone();
    end;

    if h1.find()=0 then do;
        replace;
        _rc = h1.remove();
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;ERROR: File ORACLE.HAVE.DATA is sequential. This task requires reading observations in a random order, but the engine allows only sequential access.&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;I assume this is because of the modify statement...&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Is there any way to bypass this error ? The only actual way I found to this day is to use proc sql with an update statement.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Mar 2021 11:40:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-This-task-requires-reading-obs-in-random-order-but-engine/m-p/727225#M226131</guid>
      <dc:creator>KermitTheFrog</dc:creator>
      <dc:date>2021-03-18T11:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: File XXXX is sequential. This task requires reading observations in a random order, but t</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-This-task-requires-reading-obs-in-random-order-but-engine/m-p/727241#M226142</link>
      <description>&lt;P&gt;AFAIK, hash solutions will only work with SAS datasets. The MODIFY statement can be used with caution against RDBMSs as demonstrated in this interesting paper:&amp;nbsp;&lt;A href="https://www.lexjansen.com/pnwsug/2008/CurtisMack-Modify.pdf" target="_blank"&gt;https://www.lexjansen.com/pnwsug/2008/CurtisMack-Modify.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 20:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-This-task-requires-reading-obs-in-random-order-but-engine/m-p/727241#M226142</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-03-17T20:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: File XXXX is sequential. This task requires reading observations in a random order, but t</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-This-task-requires-reading-obs-in-random-order-but-engine/m-p/727245#M226144</link>
      <description>&lt;P&gt;Thanks for your prompt answer&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;Can you tell me what could be the most efficient way to do this kind of update not using hash then ?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 20:53:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-This-task-requires-reading-obs-in-random-order-but-engine/m-p/727245#M226144</guid>
      <dc:creator>KermitTheFrog</dc:creator>
      <dc:date>2021-03-17T20:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: File XXXX is sequential. This task requires reading observations in a random order, but t</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-This-task-requires-reading-obs-in-random-order-but-engine/m-p/727280#M226168</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/374011"&gt;@KermitTheFrog&lt;/a&gt;&amp;nbsp;- It would help if you explained what your update is trying to do.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Mar 2021 00:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-This-task-requires-reading-obs-in-random-order-but-engine/m-p/727280#M226168</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-03-18T00:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: File XXXX is sequential. This task requires reading observations in a random order, but t</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-This-task-requires-reading-obs-in-random-order-but-engine/m-p/727316#M226189</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;Sure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a minimal reproducible example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
id="ID1"; tid=1; valid_from="20NOV2017"d; valid_to="21MAR2020"d; output;
id="ID2"; tid=2; valid_from="04FEB2016"d; valid_to="31MAR2020"d; output;
id="ID3"; tid=3; valid_from="20NOV2017"d; valid_to="21MAR2020"d; output;
id="ID4"; tid=4; valid_from="20NOV2017"d; valid_to="21MAR2020"d; output;
format valid_from valid_to date9.;
run;

data _update;
id="ID1"; tid=1; valid_from="01OCT2017"d; valid_to="21MAR2020"d; dim="FROM";  output;
id="ID3"; tid=3; valid_from="01OCT2017"d; valid_to="21MAR2020"d; dim="FROM"; output;
id="ID4"; tid=4; valid_from="20NOV2017"d; valid_to="30JUN2021"d; dim="TO"; output;
format valid_from valid_to date9.;
run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;What&amp;nbsp;I&amp;nbsp;am&amp;nbsp;trying&amp;nbsp;to&amp;nbsp;do&amp;nbsp;is&amp;nbsp;to&amp;nbsp;update&amp;nbsp;the&amp;nbsp;valid_from&amp;nbsp;(or&amp;nbsp;valid_to)&amp;nbsp;from&amp;nbsp;the&amp;nbsp;have&amp;nbsp;table&amp;nbsp;based&amp;nbsp;on&amp;nbsp;the&amp;nbsp;value&amp;nbsp;of&amp;nbsp;the&amp;nbsp;valid_from&amp;nbsp;(or&amp;nbsp;valid_to)&amp;nbsp;on&amp;nbsp;the&amp;nbsp;_update&amp;nbsp;table.&lt;BR /&gt;I&amp;nbsp;got&amp;nbsp;a&amp;nbsp;variable&amp;nbsp;(dim)&amp;nbsp;that&amp;nbsp;helps&amp;nbsp;me&amp;nbsp;flag&amp;nbsp;which&amp;nbsp;validity&amp;nbsp;range&amp;nbsp;to&amp;nbsp;update.&lt;BR /&gt;For&amp;nbsp;the&amp;nbsp;time&amp;nbsp;being,&amp;nbsp;the&amp;nbsp;following&amp;nbsp;seems&amp;nbsp;to&amp;nbsp;work:&lt;BR /&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;PRE&gt;proc sql;
update have t1
	   set valid_from = (select valid_from from _update t2
	   					 where t1.id = t2.id
						 	and t1.tid = t2.tid
							and t1.valid_to = t2.valid_to
							and t2.dim="FROM")
	  where catx('#',id, tid, valid_to) in (select catx('#',id, tid, valid_to)
			                        from _update t3
				                where t3.dim="FROM");
quit;
proc sql;
update have t1
	  set valid_to = (select valid_to from _update t2
		   			  where t1.id = t2.id
						and t1.tid = t2.tid
					    and t1.valid_from = t2.valid_from
						and t2.dim="TO")
		  where catx('#', id, tid, valid_from) in (select catx('#', id, tid, valid_from)  
					                   from _update t3
							   where t3.dim="TO");
quit;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;However,&amp;nbsp;using&amp;nbsp;the&amp;nbsp;catx()&amp;nbsp;function&amp;nbsp;in&amp;nbsp;the&amp;nbsp;where&amp;nbsp;statement&amp;nbsp;seems&amp;nbsp;a&amp;nbsp;bit&amp;nbsp;shaky.&amp;nbsp;I am&amp;nbsp;also&amp;nbsp;sure&amp;nbsp;there&amp;nbsp;is&amp;nbsp;a&amp;nbsp;better&amp;nbsp;way&amp;nbsp;to&amp;nbsp;do&amp;nbsp;this&amp;nbsp;in&amp;nbsp;"one&amp;nbsp;way",&amp;nbsp;without&amp;nbsp;the&amp;nbsp;dim&amp;nbsp;variable&amp;nbsp;to&amp;nbsp;be&amp;nbsp;used.&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Mar 2021 07:45:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-This-task-requires-reading-obs-in-random-order-but-engine/m-p/727316#M226189</guid>
      <dc:creator>KermitTheFrog</dc:creator>
      <dc:date>2021-03-18T07:45:27Z</dc:date>
    </item>
  </channel>
</rss>

