BookmarkSubscribeRSS Feed
harlananelson
Fluorite | Level 6

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. 

 

3 REPLIES 3
ChrisBrooks
Ammonite | Level 13

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

harlananelson
Fluorite | Level 6

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.

Reeza
Super User

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.


 

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1203 views
  • 2 likes
  • 3 in conversation