Chapter Contents

Previous

Next
SAS/AF Software: Class Dictionary

Using the Data Set Data Vector Class

The following example shows how to use several of the methods for this class. In this example, the first row of the table is read. Information about each column, such as column name, type, format, and so on, is retrieved. If the column type is character, then the character text is retrieved for that row; otherwise, the numeric value is retrieved.

length colname $ 8 format informat $ 14
       label $ 40 text $ 200 type $ 1;
 Note about code
INIT:
   datcl=loadclass('sashelp.fsp.
                    datast_m.class');
   datid=instance(datcl);
   veccl=loadclass('sashelp.
                    fsp.dsdvec.class');
   vecid=instance(veccl);
 Note about code
   call send (datid, '_setDataset',
              'sasuser.class');
 Note about code
   call send (datid, '_getNumberOfColumns',
               ncols);
   call send (vecid, '_setNumberOfColumns',
               ncols, datid);
 Note about code
   call send (vecid, '_getNumberOfColumns',
              ncols);
 Note about code
   call send (datid, '_getRow', vecid, 1);
 Note about code
   do column=1 to ncols;
      call send (vecid, '_getName',
                 column, colname);
      call send (vecid, '_getType', column,
                 type);
      call send (vecid, '_getFormat',
                 column, format);
      call send (vecid, '_getInformat',
                 column, informat);
      call send (vecid, '_getLabel',
                 column, label);
 Note about code
      put column= colname= type=;
      put format= informat= label=;
 Note about code
      if (type='N') then do;
        call send (vecid, '_getValue',
                   column, value);
        put value=;
      end;
 Note about code
      if (type='C') then do;
         call send (vecid, '_getText',
                     column, text);
         put text=;
      end;
   end;
 Note about code
   call send (datid, '_term');
   call send (vecid, '_term');
return;


Chapter Contents

Previous

Next

Top of Page

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