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.


 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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