Return to Archive

SAS Tip of the Month
Feburary 2009

When appending data for the first time, there is one message that appears in the SAS LOG that some just try to get rid of:

   NOTE: BASE data set does not exist. DATA file is being copied to BASE file.              

This occurs when the dataset represented in the BASE option does not exist -- SAS will create this dataset from the DATA option by copying the data from DATA to BASE.

A trick I use to get rid of this SAS LOG message is to create the BASE dataset with no observations from the first dataset to be appended, as the following example shows:

   13   *--------------------------------------;
   14   * Take the data from CLASS dataset in;
   15   * the SASHELP library and split into;
   16   * MALE and FEMALE;
   17   *--------------------------------------;
   18   data males;
   19      set sashelp.class;
   20      where sex='M';
   21   run;

   NOTE: There were 10 observations read from the data set SASHELP.CLASS.
         WHERE sex='M';
   NOTE: The data set WORK.MALES has 10 observations and 5 variables.

   22   data females;
   23      set sashelp.class;
   24      where sex='F';
   25   run;

   NOTE: There were 9 observations read from the data set SASHELP.CLASS.
         WHERE sex='F';
   NOTE: The data set WORK.FEMALES has 9 observations and 5 variables.

   26
   27   *--------------------------------------;
   28   * Create dataset COMBINED from MALES;
   29   * with no observations;
   30   *--------------------------------------;
   31   data combined;
   32      set males (obs=0);
   33   run;

   NOTE: There were 0 observations read from the data set WORK.MALES.
   NOTE: The data set WORK.COMBINED has 0 observations and 5 variables.

   34
   35   *--------------------------------------;
   36   * Now APPEND data;
   37   *--------------------------------------;
   38   proc append base=combined data=males force;

   NOTE: Appending WORK.MALES to WORK.COMBINED.
   NOTE: There were 10 observations read from the data set WORK.MALES.
   NOTE: 10 observations added.
   NOTE: The data set WORK.COMBINED has 10 observations and 5 variables.

   39   proc append base=combined data=females force;
   40   run;

   NOTE: Appending WORK.FEMALES to WORK.COMBINED.
   NOTE: There were 9 observations read from the data set WORK.FEMALES.
   NOTE: 9 observations added.
   NOTE: The data set WORK.COMBINED has 19 observations and 5 variables.              

The purpose of the data step creating COMBINED before the PROC APPEND call is to create the dataset COMBINED with no observations -- this is a quick step as this will only read in the variable information from the dataset MALES. The two PROC APPEND calls after that bring the data together. Without the datastep, and a note saying that the BASE data set does not exist and that the DATA file is being copied to BASE file will appear.

Hope this is useful to you.

________________________________
Updated February 17, 2009