DATA Step, Macro, Functions and more

How to use "Varlist Statement" in Proc DS2

Occasional Contributor
Posts: 7

How to use "Varlist Statement" in Proc DS2

[ Edited ]

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;

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);

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

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 ?



Here you can find the page :


Valued Guide
Posts: 595

Re: How to use "Varlist Statement" in Proc DS2

Posted in reply to NewmanChow

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

Occasional Contributor
Posts: 7

Re: How to use "Varlist Statement" in Proc DS2

Posted in reply to ChrisBrooks

Hi  ChrisBrooks ,

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


Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation