<?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: Dynamic hash column definition using existing dataset in PROC DS2 in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Dynamic-hash-column-definition-using-existing-dataset-in-PROC/m-p/258148#M57331</link>
    <description>&lt;P&gt;Scott&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess you need to set the LOCKTABLE= option on both statements. See also here &lt;A href="http://support.sas.com/documentation/cdl/en/fedsqlref/67954/HTML/default/viewer.htm#n1727x3z82r9gtn12vwrpe6rajkg.htm" target="_blank"&gt;FedSQL Statement Table Option Syntax&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See an example below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class class_cols;
   set sashelp.class;
   output class;
run;

proc ds2;
   data test(overwrite=yes);
      dcl package hash h();
      dcl double num;
      method init();
         if 0 then set class (locktable=share);
         h.definekey('name');
         h.definekey('sex');
         h.definedata('age');
         h.definedata('height');
         h.definedata('weight');
         h.dataset('{select * from class {options LOCKTABLE= SHARE} where sex=''F''}');
         h.definedone();
         num=h.num_items;
         put num=;
      end;
   enddata;
   run;
quit;
data test;set test;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bruno&lt;/P&gt;</description>
    <pubDate>Tue, 22 Mar 2016 07:53:30 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2016-03-22T07:53:30Z</dc:date>
    <item>
      <title>Dynamic hash column definition using existing dataset in PROC DS2</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dynamic-hash-column-definition-using-existing-dataset-in-PROC/m-p/258131#M57329</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class class_cols;
   set sashelp.class;
   output class;
run;

proc ds2;
   data test(overwrite=yes);
      dcl package hash h();
      dcl double num;
      method init();
         if 0 then set &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;class_cols&lt;/STRONG&gt;&lt;/FONT&gt; (locktable=share);
         h.definekey('name');
         h.definekey('sex');
         h.definedata('age');
         h.definedata('height');
         h.definedata('weight');
         h.dataset('{select * from &lt;FONT color="#FF0000"&gt;class&lt;/FONT&gt; where sex=''F''}');
         h.definedone();
         num=h.num_items;
         put num=;
      end;
   enddata;
   run;
quit;
data test;set test;run;  * to get EG to display the results from DS2 ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this fails:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class class_cols;
   set sashelp.class;
   output class;
run;

proc ds2;
   data test(overwrite=yes);
      dcl package hash h();
      dcl double num;
      method init();
         if 0 then set &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;class&lt;/STRONG&gt;&lt;/FONT&gt; (locktable=share);
         h.definekey('name');
         h.definekey('sex');
         h.definedata('age');
         h.definedata('height');
         h.definedata('weight');
         h.dataset('{select * from &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;class&lt;/STRONG&gt; &lt;/FONT&gt;where sex=''F''}');
         h.definedone();
         num=h.num_items;
         put num=;
      end;
   enddata;
   run;
quit;
data test;set test;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How do I get this 2nd example to work? &amp;nbsp;Is there a better way? &amp;nbsp;This approach is quite common in data step processing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2016 05:34:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dynamic-hash-column-definition-using-existing-dataset-in-PROC/m-p/258131#M57329</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2016-03-22T05:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic hash column definition using existing dataset in PROC DS2</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dynamic-hash-column-definition-using-existing-dataset-in-PROC/m-p/258148#M57331</link>
      <description>&lt;P&gt;Scott&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess you need to set the LOCKTABLE= option on both statements. See also here &lt;A href="http://support.sas.com/documentation/cdl/en/fedsqlref/67954/HTML/default/viewer.htm#n1727x3z82r9gtn12vwrpe6rajkg.htm" target="_blank"&gt;FedSQL Statement Table Option Syntax&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See an example below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class class_cols;
   set sashelp.class;
   output class;
run;

proc ds2;
   data test(overwrite=yes);
      dcl package hash h();
      dcl double num;
      method init();
         if 0 then set class (locktable=share);
         h.definekey('name');
         h.definekey('sex');
         h.definedata('age');
         h.definedata('height');
         h.definedata('weight');
         h.dataset('{select * from class {options LOCKTABLE= SHARE} where sex=''F''}');
         h.definedone();
         num=h.num_items;
         put num=;
      end;
   enddata;
   run;
quit;
data test;set test;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bruno&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2016 07:53:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dynamic-hash-column-definition-using-existing-dataset-in-PROC/m-p/258148#M57331</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2016-03-22T07:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic hash column definition using existing dataset in PROC DS2</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dynamic-hash-column-definition-using-existing-dataset-in-PROC/m-p/271902#M58319</link>
      <description>&lt;P&gt;Thanks that works, although I'm surprised that either the set statement or "select * from class" puts a lock on the table such that the other statement fais :-?&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 05:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dynamic-hash-column-definition-using-existing-dataset-in-PROC/m-p/271902#M58319</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2016-05-20T05:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic hash column definition using existing dataset in PROC DS2</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dynamic-hash-column-definition-using-existing-dataset-in-PROC/m-p/271906#M58320</link>
      <description>&lt;P&gt;Scott&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not know why, since both are read only.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;bruno&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 06:05:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dynamic-hash-column-definition-using-existing-dataset-in-PROC/m-p/271906#M58320</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2016-05-20T06:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic hash column definition using existing dataset in PROC DS2</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dynamic-hash-column-definition-using-existing-dataset-in-PROC/m-p/271908#M58321</link>
      <description>&lt;P&gt;Yep, my comment was more for any birdies that care to chime in. &amp;nbsp;Yes, since SET and SELECT are both readonly, &lt;U&gt;and explicitly supplying LOCKTABLE=SHARE works&lt;/U&gt;, why couldn't the underlying code do that, i.e. make both opens of the table "shared"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rhetorical question, no need to reply, but if any birdies want to chime in...or change the code...feel free &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 06:09:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dynamic-hash-column-definition-using-existing-dataset-in-PROC/m-p/271908#M58321</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2016-05-20T06:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic hash column definition using existing dataset in PROC DS2</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dynamic-hash-column-definition-using-existing-dataset-in-PROC/m-p/272027#M58324</link>
      <description>&lt;P&gt;Hi Scott&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After reading the doc on the &lt;A href="http://support.sas.com/documentation/cdl/en/ds2ref/68052/HTML/default/viewer.htm#n069zo2gxcg6rtn1v4x1ecpu2ncb.htm" target="_blank"&gt;LOCKTABLE= table option&lt;/A&gt; comes the explantion&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LOCKTABLE= Table Option&lt;BR /&gt;&lt;BR /&gt;Details&lt;BR /&gt;You can lock tables only if you are the owner or have been granted the necessary privilege.&lt;BR /&gt;If you use PROC DS2, the default value for the LOCKTABLE option is EXCLUSIVE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bruno&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 16:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dynamic-hash-column-definition-using-existing-dataset-in-PROC/m-p/272027#M58324</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2016-05-20T16:19:39Z</dc:date>
    </item>
  </channel>
</rss>

