Getting Data into SAS®



  1. Read an existing SAS dataset

If the existing dataset (olddata) is in the WORK library (temporary):

DATA newdata;
  SET olddata;
RUN; 
If the existing dataset (olddata) is in the PERM library (permanent) already allocated:
DATA newdata;
  SET perm.olddata;
RUN;
Note: SAS assumes the extension for SAS datasets and they don't need to be specified.


Return to SAS datasets.



  1. Create a SAS dataset from raw data (infile, input) (Sections 2.2-2.7)
Assume the raw (text, ascii) data file is located in a:\rawdata.dat, with variables name, age, height and weight:
DATA newdata;
  INFILE 'a:\rawdata.dat';
  INPUT name $ age height weight;

RUN;

or

FILENAME a 'a:\'; DATA newdata; INFILE a(rawdata.dat); INPUT name $ age height weight; RUN;


See INFILE and INPUT for addition details and examples of using the INFILE and INPUT statements.


Return to SAS datasets.



  1. Include data in a SAS program (data step-input, datalines/cards) (Section 2.8)

INPUT name $ age height weight;
DATALINES;
John 23 75 170
Jill 56 68 130
Alexander 18 73 168
;


Return to SAS datasets.



  1. Enter data into a SAS data table (view table) (Section 2.11)
From the menus:
TABLE à EDITOR
Double click on column label and change column (variable) attributes to name the column (variable).
Enter data into the datatable.
Save data: SAVE AS (choose WORK or a permanent open library or create/open a new library).


Return to SAS datasets.



  1. Import other types of data files-excel, dbase, oracle (import) (Section 2.17)
From the menus:
FILE à IMPORT
Follow the steps in the IMPORT wizard.


Return to SAS datasets.