【问题标题】:Proc SQL Convert decimal to minutes and seconds (SAS)Proc SQL 将十进制转换为分钟和秒 (SAS)
【发布时间】:2021-04-09 17:08:15
【问题描述】:

我正在尝试将秒转换为分秒,因此 123 秒将是 2:03(2 分 3 秒)。我正在使用 SAS,需要在 PROC SQL 中执行此操作,而不是数据步骤。

持续时间(带秒的那个)字段是数字。

谢谢

【问题讨论】:

  • 您的持续时间是否超过一个小时?那就是超过60*60的秒数?你想显示这些值吗?

标签: sas proc-sql


【解决方案1】:

使用time 格式。

proc sql;
    select 123 as time_numeric format=time.
         , put(123, time.) as time_char
    from sashelp.cars(obs=1)
    ;
quit;

如果您严格要求没有小时的分钟:

proc sql;
    select cats(scan(put(123, time.), 2, ':'), ':', scan(put(123, time.), 3, ':') )
    from sashelp.cars(obs=1)
    ;
quit;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-02-10
    • 2014-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多