http://blog.163.com/chensx_326/blog/static/1540079520078237414664/
Proc import datafile = ' ' out = dmbs = excel;
range = 'sheet1$A1:B10';
run;
一、导入导出文本文件(txt格式)、纯数据文件(dat格式);其实都是导入导出DLM文件(*.*),需要指定分隔符号。如下(以txt为例,dat同样):
1.TAB分割,第一行为变量名
PROC IMPORT OUT= WORK.a
DATAFILE= "D:\cha\1.txt"
DBMS=TAB REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;
PROC EXPORT DATA= WORK.FILELIST
OUTFILE= "D:\filelist.txt"
DBMS=TAB REPLACE;
RUN;
2.SPACE分割,第一行为变量名
PROC IMPORT OUT= YANG.WORD
DATAFILE= "D:\a\word.txt"
DBMS=DLM REPLACE;
DELIMITER='20'x;
GETNAMES=YES;
DATAROW=2;
RUN;
PROC EXPORT DATA= WORK.AA
OUTFILE= "C:\b.txt"
DBMS=DLM REPLACE;
DELIMITER='20'x;
RUN;
二、导入导出EXCEL文件(xls格式)程序如下:
PROC IMPORT OUT= WORK.ALLWORD
DATAFILE= "F:\cc.xls"
DBMS=EXCEL REPLACE;
SHEET="Sheet1$";
GETNAMES=YES;
RUN;
PROC EXPORT DATA= WORK.A
OUTFILE= "D:\export1.xls"
DBMS=EXCEL REPLACE;
SHEET="nameofsheet";
RUN;
三、导入导出ACCESS文件(mdb格式)程序如下:
PROC IMPORT OUT= WORK.aa
DATATABLE= "username"
DBMS=ACCESS REPLACE;
DATABASE="D:\all\userinfo.mdb";
RUN;
PROC EXPORT DATA= WORK.A
OUTTABLE= "export1"
DBMS=ACCESS REPLACE;
DATABASE="D:\example.mdb"; *must be an exsited database;
RUN;