SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading and Concatenating SAS Data Sets
Reading a Single Data Set


Suppose that you want to create a small data set, TestTime, from the Stress98 data set, which contains information on treadmill test time and relative tolerance levels. To create the data set, you must first reference the library where Stress98 is stored and then the library where you want to store TestTime. Then you write a DATA step to read your data and create a new data set.


General form, basic DATA step for reading a single data set:
DATA SAS-data-set;
         SET
SAS-data-set;
RUN;

where

  • SAS-data-set in the DATA statement is the name (libref.filename) of the SAS data set to be created
  • SAS-data-set in the SET statement is the name (libref.filename) of the SAS data set to be read.


After you write a DATA step to name the SAS data set to be created, you specify the data set that will be read in the SET statement. The DATA statement below creates the permanent SAS data set Drug1H, which will be stored in the SAS data library assigned the libref Lab23. The SET statement below reads the permanent SAS data set Research.CLTrials.

     data lab23.drug1h;
        set research.cltrials;
     run; 
The DATA step above reads all observations and variables from the existing data set into the new data set. When you submit this DATA step, the following messages appear in the log, confirming that the new data set was created:


SAS Log

   8  data lab23.drug1h;
   9     set research.cltrials;
  10  run;

  NOTE: The data set LAB23.DRUG1H has 21 
observations and 8 variables



back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement