Using View Descriptors in SAS Programs

Example 1: Printing Data

Printing IMS data that is described by a view descriptor is like printing any other SAS data set, as shown in the following example:
options nodate linesize=120;

proc print data=vlib.wiredata;
   title2 'Wire Transactions';
run;
The following output shows the output for the Vlib.WireData view descriptor.
Results of the PRINT Procedure
                                                  The SAS System
                                                Wire Transactions

  OBS  SSN_ACCOUNT             ACCOUNT_TYPE  WIRE_DATE WIRE_TIME   WIRE_AMOUNT WIRE_DESCRIPT

    1  335-45-3451345620145345    C          03/31/95  15:42:43    1563.23     BAD CUST_SSN
    2  434-62-1224345656336366    L          03/30/95  23:45:32    424.87      WIRED FROM SCNB 37262849393
    3  156-45-5672345689435776    S          04/06/95  12:23:42    -150.00     WIRED TO BOA 9383627274
    4  456-45-3462345620134522    C          04/06/95  13:12:34    -245.73     WIRED TO WELLS FARGO CHICAGO
    5  234-74-4612345689413263    S          04/06/95  15:45:42    -238.73     WIRED TO WELLS FARGO SAN FRANCISCO
    6  667-73-8275345620154633    S          03/31/95  15:42:43    1563.23     BAD ACCT_NUM
    7  234-74-4612345620113263    C          04/06/95  11:12:42    1175.00     WIRED FROM SCNB 73653728343
    8  156-45-5672345620123456    C          04/06/94  10:23:53    -136.29     WIRED TO SCNB 53472019836
    9  156-45-5672345620123456    C          04/06/95   9:35:53    1923.87     WIRED FROM CIBN 37284839328
   10  434-62-1224345620134564    C          04/06/95  13:23:52    -284.42     WIRED TO TVNB 837362636438
   11  667-73-8275345689454633    C          03/28/95  15:42:43    1563.23     BAD ACCT_NUM
When you use the PRINT procedure, you might want to take advantage of the OBS= and FIRSTOBS= data set options. The OBS= option enables you to specify the last observation to be processed; the FIRSTOBS= option enables you to specify the first. The options are not valid with any form of the WHERE expression. The OBS= option improves performance when the view descriptor describes a large amount of data and you just want to see an example of the output. Because each record must still be read and its position calculated, using the FIRSTOBS= option does not improve performance significantly. The POINT= and KEY= options of the MODIFY and SET statements are not currently supported by the IMS engine.
The following example uses the OBS= data set option to print the first five observations of data described by the view descriptor Vlib.WireData, which describes the WIRETRAN segment of the IMS database WireTrn:
options nodate linesize=120;

proc print data=vlib.wiredata(obs=5);
   title2 'First Five Observations Described by 
          Vlib.WireData';
run;
The following table shows the result of this example.
Results of Using the FIRSTOBS= Option
                                                 The SAS System                 
                                
                               First Five Observations Described by VLIB.WIREDATA                                
                                                                                
                                
 OBS  SSN_ACCOUNT              ACCOUNT_TYPE  WIRE_DATE  WIRE_TIME   WIRE_AMOUNT WIRE_DESCRIPT                              
                                                                                
                                
   1  335-45-3451345620145345    C           03/31/95   15:42:43    1563.23     BAD CUST_SSN              
   2  434-62-1224345656336366    L           03/30/95   23:45:32     424.87     WIRED FROM SCNB 37262849393
   3  156-45-5672345689435776    S           04/06/95   12:23:42    -150.00     WIRED TO BOA 9383627274   
   4  456-45-3462345620134522    C           04/06/95   13:12:34    -245.73     WIRED TO WELLS FARGO CHICAGO
   5  234-74-4612345689413263    S           04/06/95   15:45:42    -238.73     WIRED TO WELLS FARGO SAN FRANCISCO    
For more information about the PRINT procedure, see Base SAS Procedures Guide and SAS Language Reference: Concepts. For more information about the OBS= and FIRSTOBS= options, see SAS Data Set Options: Reference.

Example 2: Reviewing Variables

If you want to use IMS data that is described by a view descriptor in your SAS program, you can use the CONTENTS or DATASETS procedure to display the view's variable and format information. You use these procedures with view descriptors in the same way you use them with other SAS data sets.
The following example uses the DATASETS procedure to give you information about the view descriptor Vlib.WireData, which describes the data in the WIRETRAN segment of the IMS database WireTrn:
options nodate linesize=132;

proc datasets library=vlib memtype=view;
   contents data=wiredata;
   title2 ' ';
run;
The following output shows the first display of the information for this example.
Results of Using the DATASETS Procedure with a View Descriptor
                                                                                
                                DATASETS PROCEDURE                                
                                                                                  
          Data Set Name: VLIB.WIREDATA          Observations:         .           
          Member Type:   VIEW                   Variables:            6           
          Engine:        SASIOIMS               Indexes:              0           
          Created:       .                      Observation Length:   88          
          Last Modified: .                      Deleted Observations: 0           
          Protection:                           Compressed:           NO          
          Data Set Type:                        Sorted:               NO          
          Label:                                                                  
                                                                                  
                   -----Engine/Host Dependent Information-----                    
                                                                                  
                                                                                  
               -----Alphabetic List of Variables and Attributes-----              
                                                                                  
  
  #    Variable       Type    Len    Pos    Format    Informat    Label         
       --------------------------------------------------------------------------    
  
  2    ACCOUNT_TYPE   Char      1     23    $1.       $1.         ACCOUNT TYPE  
  1    SSN_ACCOUNT    Char     23      0    $23.      $23.        SSN - ACCOUNT 
  5    WIRE_AMOUNT    Num       8     40    12.2      12.2        WIRE AMOUNT   
  3    WIRE_DATE      Char      8     24    $8.       $8.         WIRE DATE     
  6    WIRE_DESCRIPT  Char     40     48    $40.      $40.        WIRE DESCRIPT 
  4    WIRE_TIME      Char      8     32    $8.       $8.         WIRE TIME     
     
As you can see from the output produced by the DATASETS procedure, the Vlib.WireData view descriptor has six variables: ACCOUNT_TYPE, SSN_ACCOUNT, WIRE_AMOUNT, WIRE_DATE, WIRE_DESCRIPT, and WIRE_TIME. The variables are listed in alphabetic order, and the column labeled with a # (pound sign) in the listing shows the order of each variable as it appears in the WireTran database segment. You cannot change a view descriptor's variable labels using the DATASETS procedure. The labels are generated from the IMS item names when the view descriptor is created.
For more information about the DATASETS procedure, see Base SAS Procedures Guide and the SAS Language Reference: Concepts.