Browsing and Updating IMS Data with SAS/FSP Procedures

Using the SAS/FSP Procedures

If your site has SAS/FSP software as well as SAS/ACCESS software, you can browse and update IMS data that is described by a view descriptor from within a SAS/FSP procedure.
You can use any of three SAS/FSP procedures: FSBROWSE, FSEDIT, and FSVIEW. The FSBROWSE and FSEDIT procedures display one observation at a time. The FSVIEW procedure produces multiple observations in a tabular format, similar to the PRINT procedure. PROC FSVIEW enables you both to browse and update IMS data, depending on which option you choose. The FSBROWSE, FSEDIT, or FSVIEW procedures can be used only with data that is accessed by a view descriptor, a PROC SQL view, a DATA step view, or a SAS data file. You cannot reference an access descriptor with any SAS procedure or in the SAS DATA step.
Note: The formats assigned by the ACCESS procedure are by default used as informats by the SAS/FSP procedures when you add or update a path of data.

Browsing Data Using the FSBROWSE Procedure

The FSBROWSE procedure enables you to look at IMS data but does not enable you to change it. For example, the following SAS statements enable you to browse one record of Vlib.CustInfo at a time:
proc fsbrowse data=vlib.custinfo;
run;
The following figure shows the last observation of the data that is described by the Vlib.CustInfo view descriptor. To browse each observation, issue the FORWARD and BACKWARD commands. Because a view descriptor can describe only one path of data in an IMS database, you can browse observations in only one path of data.
Browsing IMS Data in the FSBROWSE Window
Browsing IMS Data in the FSBROWSE Window
For more information about the FSBROWSE procedure, see "The FSBROWSE Procedure" in SAS/FSP Procedures Guide.
Note: Accessing observations by observation number is not supported for IMS view descriptors within the FSBROWSE procedure, but a WHERE command can be used to view a subset of the data.

Updating Data Using the FSEDIT Procedure

The FSEDIT procedure enables you to update the IMS data that is described by a view descriptor if the view descriptor specifies in your PSB a PCB that provides you with the appropriate level of Update access (insert, replace, delete, or all) for the database segments. For example, if the area codes used in HOME_PHONE and OFFICE_PHONE are incorrect for Richmond, you can correct them with the FSEDIT procedure.
For example, the following statements enable you to edit one record of Vlib.CustInfo at a time:
proc fsedit data=vlib.custinfo;
run;
An FSEDIT window appears that looks like the FSBROWSE window. Scroll to the observation that you want, or enter a WHERE statement to display the correct observation. You can then add or further update the information about customer , as shown in the following figure.
Updating IMS Data in the FSEDIT Window
Updating IMS Data in the FSEDIT Window
For more information about the FSEDIT procedure, see "The FSEDIT Procedure" in SAS/FSP Procedures Guide.

Browsing Data Using the FSVIEW Procedure

The FSVIEW procedure enables you to browse or update IMS data that is described by a view descriptor, depending on how you invoke the procedure.
For example, to browse IMS data in a tabular format, you could submit the following PROC FSVIEW statements in the Program Editor:
proc fsview data=vlib.custinfo;
run;
Browse mode is the default for the FSVIEW procedure. The statements produce the window shown in the following figure.
Browsing IMS Data in the FSVIEW Window
Browsing IMS Data in the FSVIEW Window

Updating Data Using the FSVIEW Procedure

To edit IMS data in a tabular format, you must add the EDIT or MODIFY option to the PROC FSVIEW statement, as shown here:
proc fsview data=vlib.custinfo edit;
run;
Note: The CANCEL command in the FSVIEW window does not cancel your changes; it ends the browse or edit session.

Specifying a SAS WHERE Statement While Browsing or Updating Data

If the IMS engine can generate SSAs from the WHERE statement, it then retrieves a subset of the IMS data. If the engine cannot generate SSAs from the WHERE statement, the WHERE statement is passed to SAS for processing. You can also use a SAS WHERE command to retrieve a subset of IMS data after you have invoked one of the SAS/FSP procedures using the PROC statements.
If you use a SAS WHERE statement, only the observations specified by that SAS WHERE statement are available. The other observations are not available until you exit the procedure. This is called a permanent WHERE clause.
If you use the SAS WHERE command, you can clear the command to make all the observations available. This is called a temporary WHERE clause.
In the following example, the FSEDIT procedure uses a SAS WHERE statement to retrieve a subset of customers from Richmond.
proc fsedit data=vlib.custinfo;
   where city='RICHMOND';
run;
The following figure shows the FSEDIT window after the statements have been submitted.
Submitting a SAS WHERE Statement While Invoking PROC FSEDIT
Submitting a SAS WHERE Statement While Invoking PROC FSEDIT
Only the two observations with a CITY value of RICHMOND are retrieved for editing; you must scroll forward to see the second observation. The word (Subset) appears after Vlib.CustInfo in the window title to remind you that the retrieved data is a subset of the data that is described by the view descriptor. You can then edit each observation by typing over any incorrect information. Issue the END command to end your editing session. If you want to cancel changes to an observation, you can issue the CANCEL command before you scroll to another observation. Once you scroll, the changes are saved.
You can also enter a SAS WHERE command to display a subset of your data. A SAS WHERE command is a SAS WHERE expression that you enter on the command line. For example, to begin the FSEDIT procedure, you can submit the following statements in the Program Editor:
proc fsedit data=vlib.custinfo;
run;
The following figure shows what the FSEDIT display looks like when the following command-line command is entered within the FSEDIT window:
where city='RICHMOND'
Entering a SAS WHERE Command in an FSEDIT Window
Entering a SAS WHERE Command in an FSEDIT Window
Only the two observations with a CITY value of RICHMOND are retrieved for editing; you must scroll forward to see the second observation. You can then edit each observation, as described earlier.
Although these examples have shown how to use a SAS WHERE statement and command with the FSEDIT procedure, you can use a SAS WHERE statement and command in the same way with the FSBROWSE and FSVIEW procedures. For more information about the SAS WHERE statement, see SAS Statements: Reference. For more information about the SAS WHERE command within the SAS/FSP procedures, see SAS/FSP Procedures Guide.

Scrolling with SAS/FSP Procedures

Scrolling through data using the FSEDIT, FSBROWSE, or FSVIEW procedures is different when you are using view descriptors instead of SAS data files. Although the FORWARD command works identically in both cases, the BACKWARD command does not.
Scrolling backward with SAS/FSP procedures can be slow when you are working with a large database, particularly when you are looking at a path of data in a record near the end of the database. To scroll backward through an IMS database, the IMS engine must read forward in the database from the beginning until it reaches the observation preceding the one that is displayed when the BACKWARD command was issued. For example, suppose the view defines 5,000 observations, and the current observation is 3,400. To scroll backward to observation 3,399, the FSEDIT procedure must sequentially read observations 1 through 3,398. This can be expensive and time consuming.

Inserting and Deleting Segments with SAS/FSP Procedures

Inserting and deleting database segments with SAS/FSP procedures is also different when you are using view descriptors rather than SAS data files.
You can use the FSEDIT and FSVIEW procedures to insert segments into one path of an IMS database on which a view descriptor is based, assuming you are using a PCB that enables you Insert access to the database segments. There are two ways to add a new segment to an IMS database using SAS/FSP procedures:
  • To insert one path of data, type ADD on the command line and press Enter. You can then enter an entire path of data, which the IMS engine inserts in the database using a path call.
  • To insert a path of data under an existing parent segment, use a WHERE statement or scroll to the parent segment under which you want to insert the path of data. If there are no child segments under the parent segment, enter the path of data and press Enter. The IMS engine inserts the new segments under the existing parent segment. If child segments do exist, display one of the paths of data and type the new data over the old path of data, making sure that you change the key field value in the segments to be inserted. The IMS engine then inserts the new segment.
If the view descriptor that you are using does not include all the variables defined in the access descriptor for the segment to be inserted, low values (hexadecimal zeros) are placed in those fields in the new segment occurrence inserted into the database. For more information about inserting segments when the SAS observations contain missing values, see Handling Missing Values in Advanced User Topics for the SAS/ACCESS Interface View Engine for IMS. For more information about how to use the ADD and DUP commands in the FSEDIT procedure and the AUTOADD and DUP commands in the FSVIEW procedure see SAS/FSP Procedures Guide.
When the DELETE command is used while the FSEDIT or FSVIEW procedure is referencing a view descriptor, the lowest-level existing database segment referenced in the view descriptor is removed permanently from the IMS database.
CAUTION:
If you delete segments using a view descriptor that references
only the upper hierarchical level segments in the database, any children of these segments are also deleted, even though those child segments are not included in the view descriptor.
For example, consider a database consisting of a root segment, a child segment under the root, and another child segment under that child. If you delete a segment in that database using a view descriptor that references only the root and one child, the DELETE command deletes the entire path of data below the root segment. There are two ways that you can delete an entire database record:
  • Use the DELETE command with a view descriptor that references the root segment only.
  • Use the DELETE command multiple times with a view descriptor that references an entire path of data in the database. Each time you use the DELETE command, only the lowest existing segment in the path is deleted.
The following example illustrates how to use the DELETE command in the FSEDIT procedure. Suppose you want to edit the IMS data that is described by Vlib.CustInfo to eliminate customers who have closed their bank accounts. If you are using a PCB that provides you with Delete authority, you can perform this function by using the FSEDIT procedure from the ACCESS window or with a PROC FSEDIT statement. Scroll forward to the observations to be deleted and enter DELETE on the command line, as shown in the following figure.
Deleting an IMS Segment in an FSEDIT Window
Deleting an IMS Segment in an FSEDIT Window
The DELETE command deletes this root segment from the IMS database that is described by Vlib.CustInfo and any child segments under it, and displays a message to that effect, as shown in the following figure.
Using the DELETE Command in the FSEDIT Window
Using the DELETE Command in the FSEDIT Window
For more information about using SAS/FSP procedures, see SAS/FSP Procedures Guide.