Browsing and Updating ADABAS Data |
Using FSBROWSE, FSEDIT, and FSVIEW |
If your site has SAS/FSP software as well as SAS/ACCESS software, you can browse and update ADABAS data from within a SAS program.
You can use three SAS/FSP procedures: FSBROWSE, FSEDIT, and FSVIEW. The FSBROWSE and FSEDIT procedures show you one ADABAS logical record at a time, whereas the FSVIEW procedure displays multiple logical records in a tabular format similar to the PRINT procedure. PROC FSVIEW enables you to both browse and update ADABAS data, depending on which option you choose.
Browsing Data Using the FSBROWSE Procedure |
The FSBROWSE procedure enables you to look at ADABAS data that is described by a view descriptor but does not enable you to change it. For example, the following SAS statements enable you to view one record at a time of the view descriptor VLIB.USACUST:
proc fsbrowse data=vlib.usacust; run;
The FSBROWSE procedure retrieves one logical record of ADABAS data at a time. To browse each logical record, issue the FORWARD and BACKWARD commands.
Updating Data Using the FSEDIT Procedure |
The FSEDIT procedure enables you to update ADABAS data that is described by a view descriptor if you have access to the data through the appropriate ADABAS and NATURAL security options. For example, the following SAS statements enable you to browse one record of VLIB.USACUST at a time:
proc fsedit data=vlib.usacust; run;
A window similar to the FSBROWSE window opens to enable you to edit the ADABAS data one observation at a time.
Note: When using PROC FSEDIT, you can cancel an edit only before you scroll. The CANCEL command redisplays the observation as it was before you began to edit it and cancels your editing changes. After you scroll, the changes are saved.
Browsing and Updating Data Using the FSVIEW Procedure |
Browse mode is the default for the FSVIEW procedure. For example, to browse ADABAS data, submit the PROC FSVIEW statement as follows:
proc fsview data=vlib.usacust; run;
The statements display the data as shown in the following output.
Results of Browsing Data Using the FSVIEW Procedure
FSVIEW: VLIB.USACUST (B) Command ===> ROW CUSTNUM STATE ZIPCODE COUNTRY 1 12345678 NC 27702 USA 2 14324742 CA 95123 USA 3 14324742 CA 95123 USA 4 14569877 NC 27514 USA 5 14569877 NC 27514 USA 6 14898029 MD 20850 USA 7 14898029 MD 20850 USA 8 14898029 MD 20850 USA 9 15432147 MI 49001 USA 10 18543489 TX 78701 USA 11 18543489 TX 78701 USA 12 18543489 TX 78701 USA 13 19783482 VA 22090 USA 14 19783482 VA 22090 USA 15 19876078 CA 93274 USA 16 19876078 CA 93274 USA
To see the rest of the accessed ADABAS data, you must scroll the window to the right multiple times. You can do this by entering the RIGHT command on the command line or by pressing the function key assigned to this command.
You can use the FSVIEW procedure to update ADABAS data. To edit the ADABAS data in a listing format, you have to add EDIT or MODIFY to the PROC FSVIEW statement, as shown in the following statement:
proc fsview data=vlib.usacust edit; run;
The same window as shown in Results of Browsing Data Using the FSVIEW Procedure appears, except the window title contains an (E) for edit, not a (B). SAS/FSP Software: Usage and Reference discusses in detail how to edit data using the FSVIEW procedure.
Note: The CANCEL command in the FSVIEW window does not cancel your changes, whether you have scrolled or not.
Specifying a SAS WHERE Expression While Browsing or Updating Data |
You can specify a SAS WHERE statement or a SAS WHERE command to retrieve a subset of ADABAS data while you are using the FSP procedures. The WHERE statement is submitted when the FSP procedure is invoked and retrieves only the observations that meet the conditions of the WHERE statement. The other observations are not available until you exit the procedure. This is called a permanent WHERE clause. A SAS WHERE command is a WHERE expression that is invoked from the command line within an FSP procedure. You can clear the command to make all the observations available so it is known as a temporary WHERE clause.
The following example of a WHERE statement retrieves the customers from California. These customers are a subset of the customers for the CUSTOMERS DDM.
proc fsview data=vlib.usacust edit; where state='CA'; run;
The following output shows the FSVIEW window after the statements have been submitted.
Results of Specifying a WHERE Statement While Updating Data
FSVIEW: VLIB.USACUST (Subset) Command ===> ROW CUSTNUM STATE ZIPCODE COUNTRY 2 14324742 CA 95123 USA 3 14324742 CA 95123 USA 15 19876078 CA 93274 USA 16 19876078 CA 93274 USA
Only the logical records with a STATE value of CA are retrieved for editing. Note that (Subset) appears after VLIB.USACUST in the window title to remind you that the data retrieved is a subset of the data that is described by the view descriptor. You can then edit each observation by typing over the information you want to modify. Issue the END command to end your editing session.
The following output shows the FSVIEW window when the subset of data is generated by the WHERE command:
where state='CA'
Results of Specifying a WHERE Command While Updating Data
FSVIEW VLIB.USACUST WHERE ... Command ===> ROW CUSTNUM STATE ZIPCODE COUNTRY 2 14324742 CA 95123 USA 3 14324742 CA 95123 USA 15 19876078 CA 93274 USA 16 19876078 CA 93274 USA
Results of Specifying a WHERE Statement While Updating Data and Results of Specifying a WHERE Command While Updating Data are identical, except (Subset) after the title is replaced with WHERE in the upper-right corner. You can then update each observation, as described earlier.
Although these examples have shown a SAS WHERE statement and a SAS WHERE command with the FSVIEW procedure, you can also retrieve a subset of data using the FSBROWSE and FSEDIT procedures. For more information about the SAS WHERE statement, refer to SAS Language Reference: Dictionary. For more information about using the SAS WHERE command within the SAS/FSP procedures, refer to SAS/FSP Software: Usage and Reference.
Adding and Deleting Data with the SAS/FSP Procedures |
Adding ADABAS data with the SAS/FSP procedures is different for view descriptors than for SAS data files. Adding ADABAS data as a result of any SAS update operation can cause the interface view engine to decide whether to add a new ADABAS logical record or to modify an existing one, for example, to add an occurrence to a periodic group.
If there are no periodic group fields accessed by the view descriptor or within the ADABAS file, doing an insert is straightforward. However, if a periodic group does exist, then doing an insert is more complicated, because the interface view engine generates multiple SAS observations from a single ADABAS record that contains a periodic group.
Values in the observation to be added are compared to values in the previous observation. If the contents of the previous observation do not help determine whether to add or modify, a new logical record is added. However, it is possible that some of the new values might already reside in the ADABAS file, which would mean that a new logical record is not necessary. This occurs if a periodic group is selected by the view descriptor, and the new data occurs only in variables corresponding to data fields that are part of that periodic group.
You can help the interface view engine resolve whether to add a new logical record or modify an existing one by specifying BY keys. For information about and examples of using BY keys, see Using a BY Key to Resolve Ambiguous Inserts.
Deleting ADABAS data with the SAS/FSP procedures is different for view descriptors than for SAS data files. When you delete a logical record, the results depend on whether the observation is part of a periodic group. If the logical record is not part of a periodic group, deleting an observation causes a logical record to be deleted from the ADABAS file. However, if the logical record is part of a periodic group, the results of deleting an observation depend on the status of the ADBDEL systems option for the interface view engine, which is set in the ADBEUSE CSECT. For more information, see System Options for PROC ACCESS and the Interface View Engine.
If ADBDEL=N (which is the default setting), the selected values for that occurrence in the periodic group are set to null (missing), but the logical record is not deleted.
The following example illustrates using the DELETE command in the FSEDIT procedure. (Note that the ADBDEL systems option is set to N.)
Suppose you want to edit the ADABAS data described by VLIB.USACUST. You can use the FSEDIT procedure with a PROC FSEDIT statement. Scroll forward to the observation to be deleted. In this example, there are three occurrences for the periodic group SIGNATURE-LIST. The following output shows the third occurrence, which you want to delete. (Notice that the variable SL_OCCUR displays the value 3, which tells you that this is the observation for the third occurrence.) Enter the DELETE command on the command line, as shown in the following output, and press ENTER.
Results of Deleting an ADABAS Logical Record
FSEDIT VLIB.USACUST Command ===> delete CUSTNUM: 18543489 STATE: TX ZIPCODE: 78701 COUNTRY: USA NAME: LONE STAR STATE RESEARCH SUPPLIERS FIRSTORD: 10SEP79 SL_OCCUR: 3 LIMIT: 100000.00 SIGNATUR: EVAN MASSEY BRANCH_2: DALLAS
The DELETE command processes the deletion and displays a message to that effect, as shown in the following output. There is no indication of what actions the interface view engine actually took.
FSEDIT VLIB.USACUST DELETED Command ===> NOTE: Observation has been deleted. CUSTNUM: ________ STATE: __ ZIPCODE: ______ COUNTRY: ____________________ NAME: _____________________________________ FIRSTORD: _______ SL_OCCUR: _________ LIMIT: __________________ SIGNATUR: ______________________________ BRANCH_2: _________________________
The entire observation seems to have been removed from the ADABAS file, but this is not the case. For the third occurrence, the interface view engine sets the values for data fields LIMIT and SIGNATUR to missing; the other data remains the same. Regardless of the actions though, the observation you deleted is no longer available for processing. For more information about using the SAS/FSP procedures, see SAS/FSP Software: Usage and Reference.
Copyright © 2007 by SAS Institute Inc., Cary, NC, USA. All rights reserved.