Chapter Contents

Previous

Next
SAS/AF Software: Class Dictionary

Using the SAS Variable Class

When you instantiate a SAS Variable object, only the object identifier is created. You then add information about a variable to the object. This step is referred to as initializing the object. To initialize a SAS Variable object, use the _setup method. This example creates a SAS Variable object and initializes it to the AGE variable in SASUSER.FITNESS:

length varname $8 label $40 type $1 format $8
               informat $8;
varclass=loadclass
         ('sashelp.fsp.variable.class');
varid=instance(varclass);
call send (varid, '_setup_', 'age',
           'sasuser.fitness');

If you list the contents of VARID, you see

( _class=2621
  DESC='SAS Variable Class'
  NAME='AGE'
  TYPE='N'
  LABEL='Age in years'
  FORMAT=''
  INFORMAT=''
  LENGTH=8
/**/
  DATAFILE=( _class=2631
             DESC='SAS Datafile Class'
             TYPE=''
             FULLNAME='SASUSER.FITNESS'
             LIBRARY=<invalid list id>[0]
             ATTRIBUTES=<invalid list id>[0]
             MEMTYPE='DATA'
            )[2645]
 )[2627]

LIBRARY and ATTRIBUTES are list identifiers. Notice that at this point, they have a value of 0, an invalid list identifier. The reason is that these values are not initialized by _setup. Use _getLibrary and _getAttributes to initialize these lists.


Chapter Contents

Previous

Next

Top of Page

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