Reading and writing data

Last changed: 10 February 2021

Reading data

To read an external file like this can be done in 3 ways. Use any of these to read the data set indata1.

After reading the data you can use proc print to see if the reading of the data was done correctly:

proc print data =indata1;

The data set can be found in the Output window or the Results Viewer. If not check the Log window.

Note: For this daata set you can see that the date is no longer in date format, but given as number with counts the number of days from January 1st, 1960. If you want to see dates formatted as dates, you need to use the format statement.

Missing values in SAS

Missing values in SAS are coded as dot ".".

  • If you import your file SAS will correctly find the missing values (empty cells in Excel) and code them as dots.
  • If you enter your data into the editor and read it from there you need to set dots for all missing values.
  • If you use the infile statement to read a file you can either first replace all Empty cells with dots in Excel or use the dsd option, e.g.

infile 'Z:\SAS\data\observed_values.csv' dlm=','  firstobs=2 dsd;