sas获取文件名及列名

研究了两天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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值