Cornell University Cornell University CISER

CISER Computing

Reading Colon or Tab Delimited Raw Data Files

Q.  My raw data file has colons as delimiters. Can I still read it into SAS? What about tab-delimited files?

A.  Yes, just about any delimiter is possible. In SAS, the default delimiter for an input raw data file is space. To specify your own delimiter you can use an INFILE option called DELIMITER= .  If needed, you can also use DSD option. When you specify DSD, SAS treats two consecutive delimiters as a missing value and removes quotation marks from character values. Here are some examples of reading a colon delimited and a tab delimited file.

Example to read a colon delimited file:

filename in 'u:\rawdata.txt';       /* this is your raw data file */
   data new;
       infile in delimiter=":";         
    /* use this for colon-delimiters */
       input var1-var20;
    run;

Example to read a tab delimited file:

filename two  'u:\data2.txt';     /* this is your raw data file */
    data new2;
       infile two  DSD delimiter='09'x;
      /* use hexidecimal code for tab delimiters */
       input var1-var10 ;
    run;