AFHood Group Blog The thoughtless yammerings of marketing junkies..

24Mar/090

SAS Proc datasets – What can’t it do?

Of all the SAS procedures, this must be one of the most flexible. Any thing related the the dataset as an entity can be done with the Proc Datasets procedure. The basic syntax is as follows:

proc datasets <options>;

<commands> <options> ;

run;

Here are only a few of the thing you can accomplish with Proc Datasets.

Copy datasets in batch or singularly. Very similar to the proc copy syntax.

proc datasets ;

copy out=target_library in=source_library ;

select dataset_list ; /* This statement is optional and only if

you want to specify the datasets to be copied. Omitting this

will copy all datasets in the source_library. */

run;

Delete a dataset. See more examples here.

proc datasets library=lib_name;

delete dataset_name;

run;

Delete all datasets in a library.

proc datasets library=lib_name kill;

run;

Rename datasets.

proc datasets library=lib_name;

change old_dataset = new_dataset;

run;

Delete all the labels in a dataset.

proc datasets library=lib_name;

modify dataset_name;

attrib _all_ label=''; /* change all to the variable name for a specific variable */

run;

Append a dataset

proc datasets library=lib_name;

append out=destination_dataset data=source_dataset;

run;

Some important options to use on the proc datasets procedure include the nolist option that suppresses the list of datasets in the library. This can become very annoying if not used. SAS will fill your log with list of datasets if you are not using the nolist option. Also, force is used often when appending data. This will force the append to occur even if the datatypes aren't matches. Memtype can be used as an option to limit the files in the library for which you will be operating. This is particularly useful when deleting datasets.

If you need assistance with you SAS programs, please give us a call. We have a dedicated team of programmers ready to tackle your problems.