使用 SAS 将字符串格式化为子字符串

发布于 2024-10-08 05:38:15 字数 315 浏览 1 评论 0原文

我是 SAS 格式的新手。

假设我有一个 NNN.xxx 形式的字符串,其中 NNN 是 z3 格式的数字。 xxx 只是一些文本。

例如

001.NUL 和 002.ABC

现在我可以定义一个格式 fff,这样 b = put("&NNN..&xxx.",fff.);仅返回 &xxx。部分?

我知道我们可以通过使用 b = substr("&NNN..&xxx.",5,3); 来实现这一点但我想要一种格式,以便我可以简单地将格式分配给变量,而不必从中创建新变量。

提前致谢。

I am new to SAS formats.

Say I have a string in the form of NNN.xxx where NNN is a number in the format of z3. and xxx is just some text.

E.g.

001.NUL and 002.ABC

Now can I define a format, fff, such that b = put("&NNN..&xxx.",fff.); returns only the &xxx. part?

I know we can achieve this by using b = substr("&NNN..&xxx.",5,3); but I want to have a format so that I can simply assign the format to a variable and not have to create a new variable out of it.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鹿港小镇 2024-10-15 05:38:16

如前所述,我认为这可以通过自定义格式与 SAS 内置字符函数(即 CAT、CATX、CATS、CATT 等)的组合来实现。

As said, I think this can be achieved thru combination of custom defined formats along with SAS builtin character functions - i.e. CAT, CATX, CATS, CATT etc...

素衣风尘叹 2024-10-15 05:38:15

可能唯一的方法是使用 SAS/TOOLKIT 编写您自己的自定义字符格式。像使用 substr() 一样创建另一个变量会容易得多。

Probably the only way is to code your own custom character format using SAS/TOOLKIT. It will be much easier to create another variable as you do with substr().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文