<?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 How to explicitly name parameters when invoking DS2 constructors and methods? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-explicitly-name-parameters-when-invoking-DS2-constructors/m-p/399841#M96865</link>
    <description>&lt;P&gt;For readability, in a data step you can explicitly name parameters for the hash object declaration, as per &lt;A title="DECLARE Statement, Hash and Hash Iterator Objects" href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002576871.htm" target="_self"&gt;SAS(R) 9.2 Language Reference&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;declare hash myhash(dataset: "table", duplicate: "r");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In PROC DS2, using the&amp;nbsp;similar syntax produces an error:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc ds2;
	package foo /overwrite=yes;
	declare package hash myhash(hashexp: 4);
	endpackage;
	run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV id="sasLogError1_1506701499876" class="sasError"&gt;&lt;FONT color="#FF0000"&gt; ERROR: Compilation error.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV id="sasLogError2_1506701499876" class="sasError"&gt;&lt;FONT color="#FF0000"&gt; ERROR: Parse encountered ':' when expecting ')'.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV id="sasLogError3_1506701499876" class="sasError"&gt;&lt;FONT color="#FF0000"&gt; ERROR: Line 64: Parse failed: declare package hash myhash(hashexp &amp;gt;&amp;gt;&amp;gt; : &amp;lt;&amp;lt;&amp;lt; 4);&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;&lt;FONT color="#000000"&gt;I tried using an equals sign instead, like invoking a macro and naming the parameters explicitly, but that doesn't work. I think the `=` is evaluated as part of a boolean equation, passing a 1 or 0 as the value.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;&lt;FONT color="#000000"&gt;Using the package methods to configure the hash might be more readable, but for brevity I'd like to just use the parameters in the constructor. And overall,&amp;nbsp;when creating user-defined packages, some methods might take a bunch of parameters, and it would be tedious and bug-prone to write and call a method to set each parameter.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;&lt;FONT color="#000000"&gt;Here's a DS2 example I think that could use some explicit parameter naming:&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;declare package hash h1([key1], [data1 data2 data3], 0, 'testdata', '', '', '', 'multidata');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Sep 2017 17:38:39 GMT</pubDate>
    <dc:creator>anonymous_user</dc:creator>
    <dc:date>2017-09-29T17:38:39Z</dc:date>
    <item>
      <title>How to explicitly name parameters when invoking DS2 constructors and methods?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-explicitly-name-parameters-when-invoking-DS2-constructors/m-p/399841#M96865</link>
      <description>&lt;P&gt;For readability, in a data step you can explicitly name parameters for the hash object declaration, as per &lt;A title="DECLARE Statement, Hash and Hash Iterator Objects" href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002576871.htm" target="_self"&gt;SAS(R) 9.2 Language Reference&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;declare hash myhash(dataset: "table", duplicate: "r");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In PROC DS2, using the&amp;nbsp;similar syntax produces an error:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc ds2;
	package foo /overwrite=yes;
	declare package hash myhash(hashexp: 4);
	endpackage;
	run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV id="sasLogError1_1506701499876" class="sasError"&gt;&lt;FONT color="#FF0000"&gt; ERROR: Compilation error.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV id="sasLogError2_1506701499876" class="sasError"&gt;&lt;FONT color="#FF0000"&gt; ERROR: Parse encountered ':' when expecting ')'.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV id="sasLogError3_1506701499876" class="sasError"&gt;&lt;FONT color="#FF0000"&gt; ERROR: Line 64: Parse failed: declare package hash myhash(hashexp &amp;gt;&amp;gt;&amp;gt; : &amp;lt;&amp;lt;&amp;lt; 4);&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;&lt;FONT color="#000000"&gt;I tried using an equals sign instead, like invoking a macro and naming the parameters explicitly, but that doesn't work. I think the `=` is evaluated as part of a boolean equation, passing a 1 or 0 as the value.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;&lt;FONT color="#000000"&gt;Using the package methods to configure the hash might be more readable, but for brevity I'd like to just use the parameters in the constructor. And overall,&amp;nbsp;when creating user-defined packages, some methods might take a bunch of parameters, and it would be tedious and bug-prone to write and call a method to set each parameter.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;&lt;FONT color="#000000"&gt;Here's a DS2 example I think that could use some explicit parameter naming:&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;declare package hash h1([key1], [data1 data2 data3], 0, 'testdata', '', '', '', 'multidata');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2017 17:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-explicitly-name-parameters-when-invoking-DS2-constructors/m-p/399841#M96865</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2017-09-29T17:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to explicitly name parameters when invoking DS2 constructors and methods?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-explicitly-name-parameters-when-invoking-DS2-constructors/m-p/400179#M97013</link>
      <description>&lt;P&gt;@anonymous_user&lt;/P&gt;
&lt;P&gt;For DS2 parameter passing is positional only as documented.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=ds2ref&amp;amp;docsetTarget=n0qpaav3a488wjn1ishk8ump7j1g.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=ds2ref&amp;amp;docsetTarget=n0qpaav3a488wjn1ishk8ump7j1g.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess you know that already and your post is more of a feature request than an actual question.&lt;/P&gt;
&lt;P&gt;Do you know that you can post such feature requests under the following link? &lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/idb-p/sas_ideas" target="_blank"&gt;https://communities.sas.com/t5/SASware-Ballot-Ideas/idb-p/sas_ideas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Oct 2017 23:13:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-explicitly-name-parameters-when-invoking-DS2-constructors/m-p/400179#M97013</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-01T23:13:34Z</dc:date>
    </item>
  </channel>
</rss>

