Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Stored procedures 如何在不使用ProcSQL的情况下在SAS中调用存储过程?_Stored Procedures_Sas - Fatal编程技术网

Stored procedures 如何在不使用ProcSQL的情况下在SAS中调用存储过程?

Stored procedures 如何在不使用ProcSQL的情况下在SAS中调用存储过程?,stored-procedures,sas,Stored Procedures,Sas,在我的合作社,我的经理要求我获取我收集的SAS输出表,然后执行一个存储过程,该过程将上传和更新任何已更改为在线KPI(关键绩效指标)excel表的数据 显然,我的老板甚至不太确定如何做到这一点,他已经编写了相当长的一段时间了 用外行的话说,这就是我需要做的: 创建收集的KPI表(完成) 将表发送到存储过程(我不想在SAS 9.3中使用ProcSQL,因为我会在太多字段中硬编码) 将存储过程读入联机数据表(完成) 如果KPI已更改(完成),则替换KPI 以下是我已经计算过的ProcSQL:为了

在我的合作社,我的经理要求我获取我收集的SAS输出表,然后执行一个存储过程,该过程将上传和更新任何已更改为在线KPI(关键绩效指标)excel表的数据

显然,我的老板甚至不太确定如何做到这一点,他已经编写了相当长的一段时间了

用外行的话说,这就是我需要做的:

  • 创建收集的KPI表(完成)

  • 将表发送到存储过程(我不想在SAS 9.3中使用ProcSQL,因为我会在太多字段中硬编码)

  • 将存储过程读入联机数据表(完成)

  • 如果KPI已更改(完成),则替换KPI

以下是我已经计算过的ProcSQL:为了保持匿名性,给出了不明确的名称:

%let id  = 'HorseRaddish';
%let pwd = 'ABC321';


proc sql;
    connect to odbc (dsn='JerrySeinfeld' uid=&id pwd=&pwd);
    execute (spKPIInsertUpdateKPIData '411', '7.2', '8808', 'M', 'NANANA', 'WorkStation', 'Testing1212', '1', '8/3/2013 10:42AM')  by odbc;
   disconnect from odbc;
quit;

run;

上面的代码工作得很好,但正如我所说的,在数百个字段的KPI计算中硬编码是一件痛苦的事情。

如果是我,并且我可以灵活地这么做,我会重写SP,从表中提取参数并上传表,然后调用SP。这一定会更快

如果不是,您可以相当轻松地编写SP行的脚本。您仍然可以在procsql中运行它,但不必手工编写

比如:

proc sql;
select cats("execute(spKPIInsertUdateKPIData '",var1,"''",var2,"','",var3,<... more ...>,"') by odbc") into :execlist separated by ';';
quit;
libname sqldb oledb init_string=whatever;
proc sql;
drop table sqldb._tempSP_KPI;
create table sqldb._tempSP_KPI as select * from <dataset containing values>;
connect to oledb (init_string=whatever);
<exec SP that uses the _tempSP_KPI table)>
quit;

quit;
这确实有一些长度限制,如果您超过20k个字符,您可能需要稍微改变它(将其切碎或使用
%include

但同样,这可能不是一个很好的方法——更好的方法是加载到表中,并从该表中更新SP。比如:

proc sql;
select cats("execute(spKPIInsertUdateKPIData '",var1,"''",var2,"','",var3,<... more ...>,"') by odbc") into :execlist separated by ';';
quit;
libname sqldb oledb init_string=whatever;
proc sql;
drop table sqldb._tempSP_KPI;
create table sqldb._tempSP_KPI as select * from <dataset containing values>;
connect to oledb (init_string=whatever);
<exec SP that uses the _tempSP_KPI table)>
quit;

quit;
libname sqldb oledb init_string=whatever;
proc-sql;
删除表sqldb.\u tempSP\u KPI;
创建表sqldb.\u tempSP\u KPI作为select*from;
连接到oledb(init_string=whatever);
退出
退出