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

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

How to define current year as a variable in proc fedsql

问题

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

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

  1. 但它不会计算并且

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

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

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

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

which doesn't evaluate and

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

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

答案1

得分: 1

使用 year(current_date)

  1. proc fedsql;
  2. select year(current_date) as "年份", *
  3. from have
  4. ;
  5. quit;

文档链接

英文:

Use year(current_date)

  1. proc fedsql;
  2. select year(current_date) as "year", *
  3. from have
  4. ;
  5. 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:

确定