Previous Page | Next Page

Managing SAS Data Libraries

Looking at a PROC DATASETS Session

The following example illustrates how PROC DATASETS behaves in a typical session. In the example, a file from one SAS data library is used to create a test file in another SAS data library. A data set is copied and its contents are described so that the output can be visually checked in order to be sure that the variables are compatible with an existing file in the test library.

The following program is arranged in groups to show which statements are executed as one task. The tasks and the action by SAS are numbered in the order in which they occur in the program.

proc datasets library=test89; 1 

   copy in=realdata out=test89; 2 
      select income88;

   contents data=income88; 3 
run;

   modify income88; 4 
      rename Sales=Sales88;

quit; 5 

The following list corresponds to the numbered items in the preceding program:

[1] Starts the DATASETS procedure and specifies the procedure input library TEST89.

[2] Copies the data set INCOME88 from the SAS data library REALDATA. SAS recognizes these statements as one task. When SAS reads the CONTENTS statement, it immediately copies INCOME88 into the library TEST89. The CONTENTS statement acts as an implied RUN statement, which causes the COPY statement to execute. This action is more noticeable if you are running SAS in the windowing environment.

[3] Describes the contents of the data set. Visually checking the output can verify that the variables are compatible with an existing SAS data set. When SAS receives the RUN statement, it describes the contents of INCOME88. Because the previous task has executed, it finds the data set in the procedure input library TEST89.

After visually checking the contents, you determine that it is necessary to rename the variable Sales. Because the DATASETS procedure is still active, you can submit more statements.

[4] Renames the variable Sales to Sales88.

[5] Stops the DATASETS procedure. SAS executes the last two statements and ends the DATASETS procedure.

Previous Page | Next Page | Top of Page