Read data from the SAS editor

Last changed: 10 February 2021

Data can also be inserted in the SAS editor directly. This is convenient if the data set is not too large, since you have the data infront of you at the same time as you do the analysis. We use the command below to read the data from the editor, see here for the complete program (a .sas file, you need SAS to open it).

data indata1;
input date: ddmmyy10. type $ concent;
cards;
19/08/2006  A     16
19/08/2006  A     14
more data lines
; run;

 

Explanations:

Data set indata1 is saved in the temporary directory WORK (It will be erased when the session is closed). See reading and writing data on how to save data permanetly in SAS.

The input statement defines which variables are read:

  • date: ddmmyy10. 
  • This is a date variable of type day, month and year in this order (ddmmyy). There are all together 10 characters (8 numbers and two spaces). If we are not sure about the form of the data we can also use anydtdte20.
  • type $
  • This reads the second column, which is a text variable. $ iindicates that this is text, if $ is not given the data column needs to be numeric. 
  • concent
  • This reads the third column, which is a numeric variable.

 The cards;  statement is used to indicate when the listing of data begins.

The program is ended with run;  When you click F8 (or submit) the program is run and the data is saved in the temporary data set indata1.

Check the log window if there are any warnings or errors. It should look like this:

data indata1;
input date: ddmmyy10. type $ concent;
cards;
 
NOTE: The data set WORK.INDATA1 has 48 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.00 seconds
 
 


Contact