如何在proc fedsql中将当前年份定义为变量。

huangapple go评论72阅读模式
英文:

How to define current year as a variable in proc fedsql

问题

如何在proc fedsql中定义当前年份?
我尝试过

%let td=%sysfunc(today(),date9.);
%put &td;
%let current_year = year(&td);
%put &current_year;

但它不会计算并且

%let td=%sysfunc(today(),date9.);
%put &td;
%let current_year = %eval(year(&td));
%put &current_year;

会给我一个错误
ERROR: Required operator not found in expression: year(24JUL2023)
英文:

How can I define the current year in proc fedsql?
I tried

%let td=%sysfunc(today(),date9.);
%put &td;
%let current_year = year(&td);
%put &current_year;

which doesn't evaluate and

%let td=%sysfunc(today(),date9.);
%put &td;
%let current_year = %eval(year(&td));
%put &current_year;

which gives me the error
ERROR: Required operator not found in expression: year(24JUL2023)

答案1

得分: 1

使用 year(current_date)

proc fedsql;
    select year(current_date) as "年份", *
    from have
    ;
quit;

文档链接

英文:

Use year(current_date)

proc fedsql;
    select year(current_date) as "year", *
    from have
    ;
quit;

Documentation

huangapple
  • 本文由 发表于 2023年7月24日 17:45:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76753226.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定