DATA Step, Macro, Functions and more

Where is the documentation for Hash functions with DS2.

Reply
Occasional Contributor
Posts: 11

Where is the documentation for Hash functions with DS2.

Where is the documentation for hash functions for use with DS2.  I found the SAS component language link here: http://documentation.sas.com/?docsetId=lecompobjref&docsetTarget=p03cettn9j89vtn1n8aq7k341k58.htm&do...

Unfortunately, this documentation does not work with

 

 

proc ds2

I don't really understand why there would be a difference, but I have tried sample code with ds2 and it does not work.  Then I have been able to accomplish the same thing with different syntax.  So there is clearly a difference.

 

Here is code from the components documentation with my `proc ds2` added.  The declaration has to change when using DS2. DS2 used the `init()` method instead of `if _n_ = 1`.  I have not been able to parameterize the `output` to accomplish a similar task.

 



data table; input key data $; datalines; 531 yellow 620 green 531 blue 908 orange 620 brown 143 purple run;

proc ds2;
data _null_; length key 8 data $ 8; if (_n_ = 1) then do; declare hash myhash; myhash = _new_ hash (dataset: "table", duplicate: "r"); rc = myhash.definekey('key'); rc = myhash.definedata('data'); myhash.definedone(); end; rc = myhash.output(dataset:"otable");

enddata; run;
quit;

It certainly would be interesting to see how to do this in DS2, but more importantly, I would like a link to the proper documentation, and possibly and explanation of why there are two separate syntaxes. 

 

Valued Guide
Posts: 595

Re: Where is the documentation for Hash functions with DS2.

Posted in reply to harlananelson

In DS2 hashes are implemented as predefined packages. You'll find the documentation on page 119 of this document http://documentation.sas.com/api/docsets/ds2pg/9.4/content/ds2pg.pdf?locale=en and the hash iterator package is documented on page 131

Occasional Contributor
Posts: 11

Re: Where is the documentation for Hash functions with DS2.

Posted in reply to ChrisBrooks

From the document you pointed to: there is the link to

http://documentation.sas.com/?docsetId=ds2ref&docsetTarget=p1cnwa3vwltaqgn1fnowe2jqxl8y.htm&docsetVe...

Your document seems to be a white paper and this link is the official documentation.

Super User
Posts: 23,773

Re: Where is the documentation for Hash functions with DS2.

Posted in reply to harlananelson

Both are versions of documentation. @ChrisBrooks is the Programmers Guide (see bottom right corner of cover page where it states documentation) and the release date is pretty new - January 11, 2018. 

In general the programmers guide is more of a tutorial type document whereas the documentation is a bit more formal.

 

 


@harlananelson wrote:

From the document you pointed to: there is the link to

http://documentation.sas.com/?docsetId=ds2ref&docsetTarget=p1cnwa3vwltaqgn1fnowe2jqxl8y.htm&docsetVe...

Your document seems to be a white paper and this link is the official documentation.


 

Ask a Question
Discussion stats
  • 3 replies
  • 86 views
  • 2 likes
  • 3 in conversation