<?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: Hash object output dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Hash-object-output-dataset/m-p/605700#M175799</link>
    <description>&lt;P&gt;Thanks for the quick responses.&amp;nbsp; Just what I needed!&lt;/P&gt;</description>
    <pubDate>Wed, 20 Nov 2019 12:25:28 GMT</pubDate>
    <dc:creator>kgflynn</dc:creator>
    <dc:date>2019-11-20T12:25:28Z</dc:date>
    <item>
      <title>Hash object output dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-object-output-dataset/m-p/605446#M175724</link>
      <description>&lt;P&gt;Hi, I have borrowed this code which works ok and I don't understand the hash object just yet.&amp;nbsp; I would like to know if there is a way to have the variable 'sourcedID' as the directory name instead of part of the filename.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example it currently creates&amp;nbsp;&lt;/P&gt;&lt;P&gt;E:\Test\ orgs_350.sas7bdat&lt;/P&gt;&lt;P&gt;E:\Test\orgs_360.sas7bdat&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;and I would like this:&lt;/P&gt;&lt;P&gt;E:\Test\350\orgs.sas7bdat&lt;/P&gt;&lt;P&gt;E:\Test\360\orgs.sas7bdat&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname e 'E:\Test';&lt;BR /&gt;data _null_;&lt;BR /&gt;if _n_=1 then do;&lt;BR /&gt;if 0 then set work.orgs;&lt;BR /&gt;declare hash h(dataset:'work.orgs(obs=0)',multidata:'y');&lt;BR /&gt;h.definekey(all:'y');&lt;BR /&gt;h.definedata(all:'y');&lt;BR /&gt;h.definedone();&lt;BR /&gt;end;&lt;BR /&gt;do until(last.sourcedid);&lt;BR /&gt;set work.orgs;&lt;BR /&gt;by sourcedId;&lt;BR /&gt;h.add();&lt;BR /&gt;end;&lt;BR /&gt;h.output(dataset:"e.orgs_" || sourcedid );&lt;BR /&gt;h.clear();&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 16:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-object-output-dataset/m-p/605446#M175724</guid>
      <dc:creator>kgflynn</dc:creator>
      <dc:date>2019-11-19T16:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Hash object output dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-object-output-dataset/m-p/605447#M175725</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10086"&gt;@kgflynn&lt;/a&gt;&amp;nbsp; The Output method creates a dataset or in other words write the contents of the Hash object to a dataset. The &lt;STRONG&gt;e.&lt;/STRONG&gt; expression in the output method basically prefixes the dataset name to two level reference name pointing to a library of a folder. Removing the prefix &lt;STRONG&gt;e. &lt;/STRONG&gt;would still create the dataset but in the work library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So basically the functionality of Hash object output method is not to create libraries, rather create only datasets if that makes sense.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could write the expression like&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(dataset:&lt;STRONG&gt;cats("e.", "orgs_" , sourcedid ); &lt;/STRONG&gt;and still means the same.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;However, having said the above, you could probably use DCREATE function and create a directory when processing each By group dynamically and point the expression of the DCREATE function in the HASH object Output method. This should be possible.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 16:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-object-output-dataset/m-p/605447#M175725</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-19T16:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Hash object output dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-object-output-dataset/m-p/605477#M175735</link>
      <description>&lt;P&gt;Unlike normal SAS code that allows you use to a quoted physical name to reference a dataset for the OUTPUT() method of the HASH object have to use the old standard MEMNAME or LIBNAME.MEMNAME format for the dataset name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you can use the LIBNAME() function to dynamically define the libref before calling the OUTPUT() method.&lt;/P&gt;
&lt;P&gt;Also if you set the DLCREATEDIR option then making the libref will create the subfolder if it does not exists (note that DLCREATEDIR will only create the terminal subdirectory, the higher levels have to already exist.).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rc=libname('E',cats("E:\test\",sourcedid));
h.output(dataset:"e.orgs");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2019 17:52:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-object-output-dataset/m-p/605477#M175735</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-19T17:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Hash object output dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-object-output-dataset/m-p/605700#M175799</link>
      <description>&lt;P&gt;Thanks for the quick responses.&amp;nbsp; Just what I needed!&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 12:25:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-object-output-dataset/m-p/605700#M175799</guid>
      <dc:creator>kgflynn</dc:creator>
      <dc:date>2019-11-20T12:25:28Z</dc:date>
    </item>
  </channel>
</rss>

