|The DATASETS Procedure|
Statements execute in the order they are written. For example, if you
want to see the contents of a data set, copy a data set, and then compare
the contents of the second data set with the first, the statements that perform
those tasks must appear in that order (that is, CONTENTS, COPY, CONTENTS).
The DATASETS procedure supports four types of RUN groups. Each RUN group is defined by the statements that compose it and by what causes it to execute.
Some statements in PROC DATASETS act as implied RUN statements because they cause the RUN group preceding them to execute.
The following list discusses what statements compose a RUN group and what causes each RUN group to execute:
If any of these statements appear in sequence in the PROC step, the sequence forms a RUN group. For example, if a REPAIR statement appears immediately after a SAVE statement, the REPAIR statement does not force the SAVE statement to execute; it becomes part of the same RUN group. To execute the RUN group, submit one of the following statements:
|COPY||another DATA or PROC step|
The SAS System reads the program statements that are associated with one task until it reaches a RUN statement or an implied RUN statement. It executes all of the preceding statements immediately, then continues reading until it reaches another RUN statement or implied RUN statement. To execute the last task, you must use a RUN statement or a statement that stops the procedure.
The following PROC DATASETS step contains five RUN groups:
libname dest 'SAS-data-library'; /* RUN group */ proc datasets; /* RUN group */ change nutr=fatg; delete bldtest; exchange xray=chest; /* RUN group */ copy out=dest; select report; /* RUN group */ modify bp; label dias='Taken at Noon'; rename weight=bodyfat; /* RUN group */ append base=tissue data=newtiss; quit;
Note: If you are running in interactive line mode, you can
receive messages that statements have already executed before you submit a
RUN statement. Plan your tasks carefully if you are using this environment
for running PROC DATASETS.
Note that if the first word of the statement (the statement name) is
in error and the procedure cannot recognize it, the procedure treats the statement
as part of the preceding RUN group.
|Using Passwords with the DATASETS Procedure|
When you are working with password-protected SAS files in the AGE, CHANGE, DELETE, EXCHANGE, REPAIR, or SELECT statement, you can specify password options in the PROC DATASETS statement or in a subordinate statement. The SAS System searches for passwords in the following order:
In the following statement, the ALTER= option provides the password RED for the SAS file BONES only:
delete xplant bones(alter=red);
In the following statement, the ALTER= option in parentheses provides the password RED for the SAS file CHEST, and the ALTER= option after the slash provides the password BLUE for the SAS file VIRUS:
delete chest(alter=red) virus / alter=blue;
In the following PROC DATASETS step, the PW= option provides the password RED for the SAS files INSULIN and ABNEG:
proc datasets pw=red; delete insulin; contents data=abneg; run;
Note: For the password for a SAS file in a SELECT statement,
the SAS System looks in the COPY statement before it looks in the PROC DATASETS
|Restricting Member Types Available for Processing|
MEMTYPE= option works slightly differently
for the CONTENTS and COPY statements. Refer to CONTENTS Statement and COPY Statement for more
The procedure searches for MEMTYPE= in the following order:
delete house lot(memtype=catalog) sales;
delete lotpix regions(memtype=data) appl / memtype=catalog;
proc datasets memtype=catalog; delete appl; run;
Note: When you use the EXCLUDE and SELECT statements, the
procedure looks in the COPY statement for the MEMTYPE= option before it looks
in the PROC DATASETS statement. For more information, see Specifying Member Types When Copying or Moving SAS Files .
Subordinate Statements and Appropriate Member Types shows the member types that you can use in each statement:
|Statement||Appropriate member types||Default member type|
|AGE||ACCESS, CATALOG, DATA, FDB, MDDB, PROGRAM, VIEW||DATA|
|CHANGE||ACCESS, ALL, CATALOG, DATA, FDB, MDDB, PROGRAM, VIEW||ALL|
|CONTENTS||ALL, DATA, VIEW||DATA (table note 1)|
|COPY||ACCESS, ALL, CATALOG, DATA, FDB, MDDB, PROGRAM, VIEW||ALL|
|DELETE||ACCESS, ALL, CATALOG, DATA, FDB, MDDB, PROGRAM, VIEW||DATA|
|EXCHANGE||ACCESS, ALL, CATALOG, DATA, FDB, MDDB, PROGRAM, VIEW||ALL|
|EXCLUDE||ACCESS, ALL, CATALOG, DATA, FDB, MDDB, PROGRAM, VIEW||ALL|
|MODIFY||ACCESS, DATA, VIEW||DATA|
|REPAIR||ALL, CATALOG, DATA||ALL (table note 2)|
|SAVE||ACCESS, ALL, CATALOG, DATA, FDB, MDDB, PROGRAM, VIEW||ALL|
|SELECT||ACCESS, ALL, CATALOG, DATA, FDB, MDDB, PROGRAM, VIEW||ALL|
TABLE NOTE 1: When DATA=_ALL_ in the CONTENTS statement, the default is ALL. ALL includes only DATA and VIEW.
TABLE NOTE 2: ALL includes only DATA and CATALOG.
Top of Page
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.