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.

24Mar/091

SAS Proc Copy – Moving multiple datasets at once

There are times when we find ourselves needing to move many datasets within a library to another location. One of many ways to do this is with the Proc Copy procedure.

The elements of a Proc Copy procedure are as follows:

proc copy in=source_library out=target_library memtype=all;

select dataset1 dataset2 dataset3;

run;

The memtype option allows you to specify what kind of member you want to move. This is optional and if you leave it off, SAS will default to ALL. Here are you available choices for this option.

ACCESS - access descriptor files (created by SAS/ACCESS software)
ALL - all member types
CATALOG - SAS catalogs
DATA - SAS data sets
FDB - financial database
MDDB - multidimensional database
PROGRAM - stored compiled SAS programs
VIEW - SAS data views

Additionally, the select statement can be left off as well. Doing so will select all datasets that meet the memtype requirements. It might be worth noting that all datasets copied will have a timestamp equal to the runtime of the procedure not equal to the source dataset.

If you have data management challenges, give us a call. We will help you design a solution that meets your needs.