研究了两天SAS,总算能实现
sas获取文件名及列名功能了。
//获取文件列名
libname da "C:\test";
data ex;
set da.qq;
run;
proc transpose data=ex out=ex2;
var _all_; //没添加前,不能完整进行转置,总会缺少某些列
run;
proc print data=ex2;
run;
//获取某一文件夹中文件名
filename indata pipe 'dir C:\tes /b';
data file_list;
length fname $50.;
infile indata truncover; /* infile statement for file names */
input fname $50.; /* read the file names from the directory */
call symput ('num_files',_n_); /* store the record number in a macro variable */
run;
//vs.net 调用
string[] sasDataText ={
"filename indata pipe 'dir C:\\tes /b';data file_list;",
" length fname $50.;",
" infile indata truncover;",
" input fname $50.;",
" call symput ('num_files',_n_);",
"run;",
"proc print;",
"run;"
};
System.Array sasArray = sasDataText;
SasWorkSpace.LanguageService.SubmitLines(ref sasDataText);
const int len = 100;
WSAS.LanguageServiceCarriageControl[] CCs;
WSAS.LanguageServiceLineType[] lineType;
string[] logLine;
SasWorkSpace.LanguageService.FlushListLines(len, out CCs, out lineType, out logLine);
上面我们调用Language Service来提交SAS DATA步和过程步,并接收LOG和LIST输出;至于如何执行SQL语句,可参考下面链接
Reading SAS Data in .Net Using ADO and ADO.NET
http://support.sas.com/kb/25/276.html
转载于:https://www.cnblogs.com/leoyo/archive/2008/07/08/1238179.html