Previous Page | Next Page

The Structure of SCL Programs

Defining Classes in SCL Programs

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.

Previous Page | Next Page | Top of Page