Previous Topic: 5.3.1 Using Multiple Cycles from a Single FileNext Topic: 5.4 Using the OUTPUT Statement


5.3.2 Using Multiple Cycles from Multiple Files


To combine observations from several CA MICS files, you must
use the MERGE statement. When merging observations, always
combine elements in the same timespan.

It is a good idea to first process cycles from each CA MICS
file separately and then use MERGE on the resulting SAS data
sets.  To illustrate this, consider the example that uses
both BATJOB files and HARCPU files:

DATA file-namea;
SET &PBATD..BATJOB04 &PBATD..BATJOB05 &PBATD..BATJOB06;
BY SYSID YEAR MONTH DAY HOUR;
IF MONTH = 12;
IF DAY = 21;
DATA file-nameb;
SET &PHARD..HARCPU04 &PHARD..HARCPU05 &PHARD..HARCPU06;
BY SYSID YEAR MONTH DAY HOUR;
IF MONTH = 12;
IF DAY = 21;

These statements produce two data sets: file-namea from
BATJOB cycles and file-nameb from HARCPU cycles.

You can now use MERGE to combine observations from file-namea
and file-nameb.  To do this, select one or more variables
common to each of these data sets and specify them on a BY
statement as follows:

DATA file-namec;
MERGE file-namea file-nameb;
BY SYSID YEAR MONTH DAY HOUR;

This produces observations in data set file-namec that
combine observations from file-namea and file-nameb that have
the same SYSID, YEAR, MONTH, DAY, and HOUR.

Note:  When using MERGE, be careful about combining
observations from combined files that are summarized in one
data set that is input to the merge but not the other.  It
can be done, but you should be aware that you are doing it so
as to correctly interpret the resulting observations.  This
is especially true for the BY variables.