How do I read a file that uses commas, tabs or spaces as delimiters to separatevariables in SAS version 8?
It is quite easy to read a file that uses a comma as a delimiter using
inSAS version 8. There are two slightly different ways of reading a comma delimitedfile using
. In SAS version 8, a comma delimited file can be consideredas a special type of external file with special file extension .csv, which stands for comma-separated-variables. We show here the first sample program making use of this feature. Let's say we have following data stored in a file called
AMC,22,3,2930,0,11:11 AMC,17,3,3350,0,11:30 AMC,22,,2640,0,12:34 Audi,17,5,2830,1,13:20 Audi,23,3,2070,1,11:11
Then the following
statement will read it in and create a temporary dataset called
As you can see in the output below, the data was read properly. Also notice that SAScreate default variable names as VAR1-VARn when variables names are not presentin the raw data file.
VAR1 VAR2 VAR3 VAR4 VAR5 VAR61 AMC 22 3 2930 011:112 AMC 17 3 3350 011:303 AMC 22 . 2640 012:344 Audi 17 5 2830 113:205 Audi 23 3 2070 111:11
ou might have a file where you have the names at the top of the file like the one below. With such a file you would like SAS to use the variable names from the file(e.g.,