Read in file using multiple delimiters

  • Author: admin
  • Filed under: Auto-cars
  • Date: Mar 12,2008

It is possible to read in file using multiple delimiters. The example file below uses either exclamation points or plus signs as delimiters.
22!2930!409917+3350+474922!2640!379920+3250+481615+4080!7827
By using delimiter=’!+’ on the infile statement, SAS will recognize both of these as valid delimiters.
DATA cars;  INFILE ‘readdel2.txt’ DELIMITER=’!+’ ;  INPUT mpg weight price;RUN; PROC PRINT DATA=cars;RUN;
As you can see in the output below, the data was read properly.
OBS    MPG    WEIGHT    PRICE 1      22     2930      4099 2      17     3350      4749 3      22     2640      3799 4      20     3250      4816 5      15     4080      7827