简体   繁体   English

在SAS中将字符串与日期连接起来,例如

[英]concatenate string with date in SAS eg

I need to create a computed column in SAS with the combination of the string 'ULPDT_' and the result from the today() function. 我需要在SAS中使用字符串'ULPDT_'和today()函数的结果组合创建一个计算列。 so that my result looks like this: ULPDT_20190101. 这样我的结果如下所示:ULPDT_20190101。 Here is my non-functional code for the advanced expression: 这是我的高级表达式的非功能代码:

t1.SourceFile='ULPDT_'||PUT(today(), yyddmmn8.)

year-day-month, YYYYDDMM , is not a normal representation for date, you might actually want year-month-day YYYYMMDD year-day-month YYYYDDMM不是日期的常规表示形式,您实际上可能希望使用YYYYDDMM -month-day YYYYMMDD

t1 is indicative of an EG generated join wherein the t1 is a table alias. t1表示EG生成的联接,其中t1是表别名。 If you are editing the code of a join node, and the problematic statement is part of a select clause, the correct SQL syntax might be 如果您正在编辑联接节点的代码,而有问题的语句是select子句的一部分,则正确的SQL语法可能是

'ULPDT_'||PUT(today(), yymmddn8.) as t1.SourceFile

Hand coded example (versus EG visual join): 手工编码的示例(与EG可视连接相对):

proc sql;
  create table x as 
  select 
    'ULPDT_'||PUT(today(), yymmddn8.) as SourceFile
  from 
    sashelp.class(obs=1)
  ;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM