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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1231 views
  • 0 likes
  • 2 in conversation