BookmarkSubscribeRSS Feed
snorex
Fluorite | Level 6

For readability, in a data step you can explicitly name parameters for the hash object declaration, as per SAS(R) 9.2 Language Reference:

 

declare hash myhash(dataset: "table", duplicate: "r");

In PROC DS2, using the similar syntax produces an error:

proc ds2;
	package foo /overwrite=yes;
	declare package hash myhash(hashexp: 4);
	endpackage;
	run;
quit;
ERROR: Compilation error.
ERROR: Parse encountered ':' when expecting ')'.
ERROR: Line 64: Parse failed: declare package hash myhash(hashexp >>> : <<< 4);
 
I tried using an equals sign instead, like invoking a macro and naming the parameters explicitly, but that doesn't work. I think the `=` is evaluated as part of a boolean equation, passing a 1 or 0 as the value.
 
Using the package methods to configure the hash might be more readable, but for brevity I'd like to just use the parameters in the constructor. And overall, when creating user-defined packages, some methods might take a bunch of parameters, and it would be tedious and bug-prone to write and call a method to set each parameter.
 
Here's a DS2 example I think that could use some explicit parameter naming:
 
declare package hash h1([key1], [data1 data2 data3], 0, 'testdata', '', '', '', 'multidata');

 

1 REPLY 1
Patrick
Opal | Level 21

@snorex

For DS2 parameter passing is positional only as documented.

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

 

I guess you know that already and your post is more of a feature request than an actual question.

Do you know that you can post such feature requests under the following link? https://communities.sas.com/t5/SASware-Ballot-Ideas/idb-p/sas_ideas

 

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 835 views
  • 1 like
  • 2 in conversation