|
|
|
||||
|
|
|||||
It is quite easy to read a file that uses a comma as a delimiter using proc export in SAS version 8. There are two slightly different ways of writing out a comma delimited file using proc export. A comma delimited file can be considered as a special type of external file with extension .csv whish 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 SAS that we want to output it to a comma delimited file called mydata.csv.
Obs MAKE MPG WEIGHT PRICE 1 AMC Concrod 22 2930 4099 2 AMC Pacer 17 3350 4749 3 AMC Sprint 22 2640 3799 4 Buick Century 22 3250 4816 5 Buick Electra 15 4080 7827
Then the following program will output it into a tab delimited data file called tab2.txt in the directory "c:\dissertation".
proc export data=mydata outfile='c:\dissertation\mydata.csv' dbms=csv replace; run;
Another way of writing a tab delimited file is to consider a comma as an ordinary delimiter. Here is a program that shows how to use the delimiter option to write out a file just like we did above. Now we can save it just as a text file.
proc export data=mydata outfile='c:\dissertation\mydata.txt' dbms=dlm replace; delimiter=","; run;
It is quite easy to read a file that uses a tab as a delimiter using proc export in SAS version 8. There are two slightly different ways of writing out a tab delimited file using proc export. In SAS version 8, a tab delimited file can be considered as a special type of external file. We show here the first sample program making use of this feature. Let's say we have following data stored SAS that we want to output to a tab delimited file called tab2.txt.
Obs MAKE MPG WEIGHT PRICE 1 AMC Concrod 22 2930 4099 2 AMC Pacer 17 3350 4749 3 AMC Sprint 22 2640 3799 4 Buick Century 22 3250 4816 5 Buick Electra 15 4080 7827
Then the following program will output it into a tab delimited data file called tab2.txt in the directory "c:\dissertation".
proc export data=mydata outfile='c:\dissertation\tab2.txt' dbms=tab replace; run;
Another way of writing a tab delimited file is to consider a tab as an ordinary delimiter. Here is a program that shows how to use the delimiter option to write out a file just like we did above.
proc export data=mydata outfile='c:\dissertation\tab2.txt' dbms=dlm replace; delimiter='09'x; run;
It is very easy to write out a file that uses a space as a delimiter to separate variables using proc export in SAS version 8. Consider the following sample data file below.
Obs MAKE MPG WEIGHT PRICE 1 AMC 22 2930 4099 2 AMC 17 3350 4749 3 AMC 22 2640 3799 4 Buick 20 3250 4816 5 Buick 15 4080 7827
Here is a sample program that writes out a space delimited text file into the directory "c:\dissertation".
proc export data=mydata outfile='c:\dissertation\spc1.txt' dbms=dlm replace; run;
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services