BookmarkSubscribeRSS Feed
NewmanChow
Fluorite | Level 6

Hello Everyone :

   The "Variable Lists" page describes you can "Passing Variable List Arguments",  I want

to test Varlist statement usage, like this :  (SAS 9.4M5  Win x64)

 

data class;
set sashelp.class;
run;

proc ds2;
data x(overwrite=yes);
/*dcl double age height weight;*/
dcl double y;
varlist vars [age height weight];

method varmean(varlist vars) returns double;
declare double rst;
rst = mean(of vars);
end;

method run();
set class;
y = varmean([age height weight]);
end;
enddata;
run;
quit;

then I got a "ERROR: Invalid variable list. vars is not a global scalar variable."

 

Do you know how to use it ,or some paper introduce it ?

Thanks!

 

Here you can find the page :

http://documentation.sas.com/?docsetId=ds2pg&docsetTarget=p1ko0gchlvwonyn173udvwbvspks.htm&docsetVer...

 

3 REPLIES 3
ChrisBrooks
Ammonite | Level 13

I must admit I've not used earliest before and I can't get it to work either. There are a couple of errors in your code though which won't help:

 

1. The variable height is misspelt in your varlist declaration; and

2. DS2 can't access the SASHELP library so you'll have to copy CLASS to another library before running the code

 

It might be worth raising a track with SAS for this as I can't see why it won't work as described in the documentation

NewmanChow
Fluorite | Level 6

Hi  ChrisBrooks ,

    Thank you for your feedback . I have fixed the Question and raising a track .

 

NewmanChow
Fluorite | Level 6
Here is SAS Technical Support feedback:
“On the issue, our developer fedback

The DS2 variable list was developed to fulfill a need of DS2 C packages, and it has very limited functionality supporting native DS2 packages and methods. Currently, functionality is NOT provided to extract values from the variables in a variable list in DS2 code.”

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1361 views
  • 0 likes
  • 2 in conversation