SAS连接变量
我想与从当前时间戳检索的微秒连接一个字符串“ AT”,但它无法正常工作。我可以得到一些帮助吗?
proc sql;
select * into :timestampcur
from connection to db2
(select char(CURRENT TIMESTAMP)
from sysibm.sysdummy1
);
quit;
%put current_timestamp=×tampcur.;
%let X =
%sysfunc(compress ( %sysfunc(substr(¤t_timestamp.,21,6))));
%let Y = "AT" || &X.;
%put Y=&Y.;
Output:
Y = "AT" || 335491
I want to concatenate a string "AT" with the microseconds retrieved from the current timestamp, but it s not working as expected. Can i get some help please?
proc sql;
select * into :timestampcur
from connection to db2
(select char(CURRENT TIMESTAMP)
from sysibm.sysdummy1
);
quit;
%put current_timestamp=×tampcur.;
%let X =
%sysfunc(compress ( %sysfunc(substr(¤t_timestamp.,21,6))));
%let Y = "AT" || &X.;
%put Y=&Y.;
Output:
Y = "AT" || 335491
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您只是谈论将字符串存储到宏变量中,则只需从代码中删除不需要的字符即可。
请注意,您的代码似乎假设DB2表达式
将返回一个至少26个字节长的字符串,而没有任何领先空间,并且字节21-26是代表毫秒的数字。
If you are talking about just storing the string into a macro variable then just remove the unneeded characters from your code.
Note that your code seems to be assuming that the DB2 expression
will return a string that is at least 26 bytes long without any leading spaces and that the bytes 21-26 are the digits that represent milliseconds.
为什么不首先创建两个大型载体呢?
Why not create two macrovariables in the first place?
DB2中的时间戳值将作为SAS DateTime值返回,该值是Epoch 01Jan1960:00:00:00:00:00:00:00:00:00。
A TIMESTAMP value in DB2 will be returned as a SAS datetime value, which is decimal seconds from epoch 01jan1960:00:00:00.