gpt4 book ai didi

sas - 在 SAS 中提取字符串的左侧部分?

转载 作者:行者123 更新时间:2023-12-02 06:33:31 26 4
gpt4 key购买 nike

是否有一个函数 SAS proc SQL 可以用来提取字符串的左侧部分。它类似于 LEFT 函数 sql server。在 SQL 中,我有 left(11111111, 4) * 9 = 9999,我想在 SAS proc SQL 中使用类似的东西。任何帮助将不胜感激。

最佳答案

我觉得您想重复子串而不是相乘,所以我添加了 REPEAT 函数只是出于好奇。

proc sql;
select
INPUT(SUBSTR('11111111', 1, 4), 4.) * 9 /* if source is char */
, INPUT(SUBSTR(PUT(11111111, 16. -L), 1, 4), 4.) * 9 /* if source is number */
, REPEAT(SUBSTR(PUT(11111111, 16. -L), 1, 4), 9) /* repeat instead of multiply */
FROM SASHELP.CLASS (obs=1)
;
quit;

关于sas - 在 SAS 中提取字符串的左侧部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26362826/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com