继续之前的读书笔记,废话少说,直奔主题。
四.连接数据库的方式
libname形式:
Oracle 链接:Libname
DB2链接:libname hsdb db2 user=xxx password="xxx"
passthrough方式(通过connect语句简历sas与外界数据库之间的 通信):
Proc sql ;
Quit;
import方式(适用于txt、csv、excel、access等文件的导入)
libname IBMSHCU oracle user=bi password=test123 path=ibmshcu;
%let filepath=C:\Documents and Settings\Administrator\My Documents\01 work\01 project\cun;
%let filemonth=201202;
proc import datafile="&filepath.\副本存费赠费清单2月.xls"
run;
data
set newcharge_calllist_&filemonth.;
rename
run;
data
set gcl_newcharge_calllist_&filemonth.;
run;
除了以上代码之外,还可以通过菜单的方式操作,通过file菜单下面有个import的菜单进行;
input方式(最复杂最不常用的方式)
另一种导入方式,不需要改列名:
libname IBMSHCU oracle user=bi password=test123 path=ibmshcu;
%let filepath=C:\Documents and Settings\Administrator\My Documents\01 work\01 project\cun;
%let filemonth=201112;
data
length
infile "&filepath.\充值送实物2011-12.TXT" dsd dlm='|' missover end=last firstobs=2;
do until(last);
input
output;
end;
drop order;
run;