<?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 Does &amp;quot;definekey&amp;quot; enforce uniqueness in a hash object? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Does-quot-definekey-quot-enforce-uniqueness-in-a-hash-object/m-p/560110#M10425</link>
    <description>&lt;P&gt;From a practice exam:&lt;/P&gt;&lt;P&gt;-----------&lt;/P&gt;&lt;P&gt;The dataset Cars contains observations listing hte Make, Model and Country of Origin of 300+ vehicles. Consider the SAS code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data_null_;

attrib Make length=$15 Label="Make Name";

declare hash Makelist(dataest:'cars', ordered:'yes');

Makelist.definekey('Make');

Makelist.definedone();

rc=Makelist.output(dataset: 'Manufacturer');

run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the result of running this program?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A) The manufacturer dataset contains unique values of Make in ascending order&lt;/P&gt;&lt;P&gt;B) The manufacturer Dataset contains unique values of Make in the original order as the input data.&lt;/P&gt;&lt;P&gt;C)&amp;nbsp;The manufacturer Dataset contains a copy of the Cars dataset in order&lt;/P&gt;&lt;P&gt;D)&amp;nbsp;The manufacturer Dataset contains a single observation as the data step iterates only once.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I answered C but the correct answer is A. Does this then mean that the definekey statement enforces uniqueness on those variable values, similarly to the PRIMARY KEY constraint?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 May 2019 12:25:02 GMT</pubDate>
    <dc:creator>Syntas_error</dc:creator>
    <dc:date>2019-05-20T12:25:02Z</dc:date>
    <item>
      <title>Does "definekey" enforce uniqueness in a hash object?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Does-quot-definekey-quot-enforce-uniqueness-in-a-hash-object/m-p/560110#M10425</link>
      <description>&lt;P&gt;From a practice exam:&lt;/P&gt;&lt;P&gt;-----------&lt;/P&gt;&lt;P&gt;The dataset Cars contains observations listing hte Make, Model and Country of Origin of 300+ vehicles. Consider the SAS code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data_null_;

attrib Make length=$15 Label="Make Name";

declare hash Makelist(dataest:'cars', ordered:'yes');

Makelist.definekey('Make');

Makelist.definedone();

rc=Makelist.output(dataset: 'Manufacturer');

run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the result of running this program?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A) The manufacturer dataset contains unique values of Make in ascending order&lt;/P&gt;&lt;P&gt;B) The manufacturer Dataset contains unique values of Make in the original order as the input data.&lt;/P&gt;&lt;P&gt;C)&amp;nbsp;The manufacturer Dataset contains a copy of the Cars dataset in order&lt;/P&gt;&lt;P&gt;D)&amp;nbsp;The manufacturer Dataset contains a single observation as the data step iterates only once.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I answered C but the correct answer is A. Does this then mean that the definekey statement enforces uniqueness on those variable values, similarly to the PRIMARY KEY constraint?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 12:25:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Does-quot-definekey-quot-enforce-uniqueness-in-a-hash-object/m-p/560110#M10425</guid>
      <dc:creator>Syntas_error</dc:creator>
      <dc:date>2019-05-20T12:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Does "definekey" enforce uniqueness in a hash object?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Does-quot-definekey-quot-enforce-uniqueness-in-a-hash-object/m-p/560124#M10427</link>
      <description>&lt;P&gt;Yes, the correct answer is A.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First of all, only the &lt;STRONG&gt;Make&amp;nbsp;&lt;/STRONG&gt;variable is read into the hash object. Therefore, the manufacturer data set can not contain a copy of the Cars data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondly, when the &lt;A href="https://documentation.sas.com/?docsetId=lecompobjref&amp;amp;docsetTarget=p00ilfw5pzcjvtn1nfya9863fozd.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;&lt;STRONG&gt;Duplicate Argument Tag&lt;/STRONG&gt;&lt;/A&gt;&amp;nbsp;is not specified with the value &lt;STRONG&gt;'Y'&lt;/STRONG&gt;, only the first value for each unique value of &lt;STRONG&gt;Make&amp;nbsp;&lt;/STRONG&gt;is read into the hash object. If you specified the code like below, all the values of &lt;STRONG&gt;Make&amp;nbsp;&lt;/STRONG&gt;(including duplicates) will be read into the hash object and consequently a part of the&amp;nbsp;manufacturer data set&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;

attrib Make length=$15 Label="Make Name";

declare hash Makelist(dataset:'sashelp.cars', multidata:'Y', ordered:'yes');

Makelist.definekey('Make');

Makelist.definedone();

rc=Makelist.output(dataset: 'Manufacturer');

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 May 2019 13:31:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Does-quot-definekey-quot-enforce-uniqueness-in-a-hash-object/m-p/560124#M10427</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-20T13:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: Does "definekey" enforce uniqueness in a hash object?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Does-quot-definekey-quot-enforce-uniqueness-in-a-hash-object/m-p/560126#M10429</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/254512"&gt;@Syntas_error&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/254512"&gt;@Syntas_error&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Does this then mean that the definekey statement enforces uniqueness on those variable values, similarly to the PRIMARY KEY constraint?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, it is the default &lt;FONT face="courier new,courier"&gt;multidata:'no'&lt;/FONT&gt; argument tag (in the parentheses after "&lt;FONT face="courier new,courier"&gt;Makelist&lt;/FONT&gt;" in the DECLARE statement) that makes &lt;FONT face="courier new,courier"&gt;Makelist&lt;/FONT&gt; a hash object with unique keys (which are then specified with the DEFINEKEY method).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(Also, note the typo in "&lt;FONT face="courier new,courier"&gt;dataest&lt;/FONT&gt;".)&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 13:32:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Does-quot-definekey-quot-enforce-uniqueness-in-a-hash-object/m-p/560126#M10429</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-05-20T13:32:44Z</dc:date>
    </item>
  </channel>
</rss>

