Chapter Contents

Previous

Next
SAS Component Language: Reference

Defining Classes

Classes define data and the operations that you can perform on that data. You define classes with the CLASS statement. For example, the following code defines a class, Simple, that defines an attribute named total and implements a method named addNums:


Example Class Definition
class Simple; public num total; addNums: public method n1:num n2:num return=num; total=n1+n2; return(total); endmethod; endclass;

The CLASS statement does not have to implement the methods. The methods may be only declared. For example:

class Simple;
  public num total;
  
  addNums: public method n1:num n2:num return=num
       / (scl=work.a.simMeth.scl');
endclass;
The code to implement the method is contained in work.a.simMeth.scl (see USECLASS Block for the addNums Method).

For more information about defining and using classes, see SAS Object-Oriented Programming Concepts; ; and CLASS.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.