<?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: PROC DS2 - END= dataset option in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/401220#M66752</link>
    <description>&lt;P&gt;Hi Chris,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This helped, Thanks a lot for being so kind to&amp;nbsp;illustrate the functionalities of&amp;nbsp;SQLSTMT package!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Dilip&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Oct 2017 07:58:06 GMT</pubDate>
    <dc:creator>DCL</dc:creator>
    <dc:date>2017-10-05T07:58:06Z</dc:date>
    <item>
      <title>PROC DS2 - END= dataset option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/400573#M66723</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just realized that dataset END option is not possible in DS2:&lt;/P&gt;
&lt;P&gt;&amp;lt;&amp;gt;&lt;/P&gt;
&lt;P&gt;do until(eof);&lt;/P&gt;
&lt;P&gt;set datasetName (locktable=share) end=eof;&lt;/P&gt;
&lt;P&gt;&amp;lt;&amp;gt;&lt;/P&gt;
&lt;P&gt;ERROR: Compilation error.&lt;/P&gt;
&lt;P&gt;ERROR: Parse encountered END when expecting ';'.&lt;/P&gt;
&lt;P&gt;ERROR: Line 0: Parse failed:&amp;nbsp;datasetName (locktable=share) &amp;gt;&amp;gt;&amp;gt; end &amp;lt;&amp;lt;&amp;lt; =eof; arrayName[&lt;FONT face="Courier New"&gt;arKey&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My intention is to load the lookup data to temporary array so that I could use it while processing the main fact table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I managed to load the arrays using a data-&amp;gt; run method&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;method run();&lt;/P&gt;
&lt;P&gt;set datasetName (locktable=share);&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; arrayName[arKey&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, arIndex] = dsField1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;end;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;enddata;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Now, I need to access this array while&amp;nbsp;processing my fact table. Unfortunately I am short of ideas to use it in the same DATA step in DS2.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Could anybody please help me?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Thanks in advance!&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;P.S- I have&amp;nbsp;multiple look up tables to be loaded into arrays and it is too big for loading&amp;nbsp;into hashes&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2017 12:40:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/400573#M66723</guid>
      <dc:creator>DCL</dc:creator>
      <dc:date>2017-10-03T12:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DS2 - END= dataset option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/400679#M66729</link>
      <description>&lt;P&gt;Could you put the readin of data for the lookup table in a method init? Then the run method could access the lookup values,right?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2017 17:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/400679#M66729</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-03T17:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DS2 - END= dataset option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/400853#M66735</link>
      <description>Hi Mark,&lt;BR /&gt;&lt;BR /&gt;From what I understood only run method has the implicit loop to read through all the dataset observations. Can init be used to read through all the observations?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Dilip</description>
      <pubDate>Wed, 04 Oct 2017 02:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/400853#M66735</guid>
      <dc:creator>DCL</dc:creator>
      <dc:date>2017-10-04T02:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DS2 - END= dataset option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/400929#M66739</link>
      <description>&lt;P&gt;I did try to load the lookup tables in init() :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;method init();&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;if &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; then set dsName (locktable=share);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;do rLoop=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; to &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;dsObs.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; put rLoop=;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set&amp;nbsp;dsName (locktable=share);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;arrayName[arKey + &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,arIndex] = dsField1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, now I get following errors:&lt;/P&gt;
&lt;P&gt;rloop=1&lt;/P&gt;
&lt;P&gt;ERROR: Integer divide by zero&lt;/P&gt;
&lt;P&gt;ERROR: Integer divide by zero&lt;/P&gt;
&lt;P&gt;ERROR: General error&lt;/P&gt;
&lt;P&gt;ERROR: Access violation&lt;/P&gt;
&lt;P&gt;ERROR: Access violation&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anybody have any clue on this?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 12:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/400929#M66739</guid>
      <dc:creator>DCL</dc:creator>
      <dc:date>2017-10-04T12:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DS2 - END= dataset option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/401005#M66741</link>
      <description>&lt;P&gt;Can you tell us why you want to use END - it's not clear to me why it's necessary in this case. If you give us some more of the code we might be able to offer an alternative way of doing what you want.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 14:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/401005#M66741</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-10-04T14:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DS2 - END= dataset option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/401085#M66742</link>
      <description>Hi Chris,&lt;BR /&gt;&lt;BR /&gt;I want to convert something like following into DS2:&lt;BR /&gt;data output;&lt;BR /&gt;&lt;BR /&gt;retain f1 0;&lt;BR /&gt;array ar1(%eval(&amp;amp;maxLookupKey.+1),3) 8 _temporary_;&lt;BR /&gt;IF _N_=1 THEN DO;&lt;BR /&gt;do until(eof1);&lt;BR /&gt;  set lookup1 end=eof1;&lt;BR /&gt;ar1(lookupKey+1,1)=f1;&lt;BR /&gt;ar1(lookupKey+1,2)=f2;&lt;BR /&gt;ar1(lookupKey+1,3)=f3;&lt;BR /&gt;end;&lt;BR /&gt;END;&lt;BR /&gt;set factTable;&lt;BR /&gt;by field1;&lt;BR /&gt;&lt;BR /&gt;if first.field1 then do;&lt;BR /&gt; f1=ar1(field1+1,1);&lt;BR /&gt; .&lt;BR /&gt; .&lt;BR /&gt; .&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;So, i am stuck with DS2 while trying to read through the datasets that I use to load into arrays which I can later use while processing the fact table.&lt;BR /&gt;&lt;BR /&gt;I hope the above code helps in conveying my requirement. If not, tomorrow I shall give a working version of the code with some sample data.&lt;BR /&gt;&lt;BR /&gt;Thanks, &lt;BR /&gt;Dilip</description>
      <pubDate>Wed, 04 Oct 2017 17:44:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/401085#M66742</guid>
      <dc:creator>DCL</dc:creator>
      <dc:date>2017-10-04T17:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DS2 - END= dataset option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/401177#M66750</link>
      <description>&lt;P&gt;You can load the contents of a data set into an array in the INIT&amp;nbsp;method if you use the SQLSTMT package&amp;nbsp;&lt;A href="http://documentation.sas.com/?docsetId=ds2ref&amp;amp;docsetTarget=p154ftg7h2x9zqn11o5g7yltm3cl.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=ds2ref&amp;amp;docsetTarget=p154ftg7h2x9zqn11o5g7yltm3cl.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt; and use a FEDSQL SELECT to bring in one row at a time with the FETCH method inside a loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've created a small example program which&amp;nbsp;first creates two data sets and then loads one into an array inside the INIT method. Then, when the RUN method executes the contents of that array are retrieved and used to calculate the product of the number from the array and the second data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
	infile datalines;
	input x;
	datalines;
2
4
6
8
;
run;

data two;
	infile datalines;
	input y;
	datalines;
10
12
14
16
;
run;

proc ds2;
	data three(keep=(x,y,z)) / overwrite=yes;
		dcl int n[4];
		dcl int counter x y z;
		retain counter;
		method init();
			dcl package sqlstmt stmt('select x from one');
			
			stmt.execute();
			stmt.bindResults([x]);
			counter=1;
			do while (stmt.fetch()=0);
				n[counter]=x;
				counter=counter+1;
			end;
		end;
		
		method run();			
			set two;
			if _n_=1 then counter=1;			
			x=n[_n_];			
			z=x*y;
			counter=counter+1;					
		end;	
	enddata;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You should be able to use this technique of loading the array in the INIT method in your code - please let me know if there's anything in there you don't follow.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 00:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/401177#M66750</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-10-05T00:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: PROC DS2 - END= dataset option</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/401220#M66752</link>
      <description>&lt;P&gt;Hi Chris,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This helped, Thanks a lot for being so kind to&amp;nbsp;illustrate the functionalities of&amp;nbsp;SQLSTMT package!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Dilip&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 07:58:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-DS2-END-dataset-option/m-p/401220#M66752</guid>
      <dc:creator>DCL</dc:creator>
      <dc:date>2017-10-05T07:58:06Z</dc:date>
    </item>
  </channel>
</rss>

