gpt4 book ai didi

sas - 为什么我的宏中的报价不平衡?

转载 作者:行者123 更新时间:2023-12-02 09:32:14 25 4
gpt4 key购买 nike

我有一个包含一些注释的宏,因为我擅长记录我的代码。由于某种原因,当我运行这个宏时,我得到了一个悬挂的报价。为什么?

复制此内容的测试宏:

%macro testme;
* Comment that is in my macro that doesn't work;
proc freq data=sashelp.class;
run;

%mend testme;

%testme;

第一次执行时它完全失败,第二次执行时它给我消息错误:此%MEND语句没有匹配的%MACRO语句。

最佳答案

在 SAS 宏语言中,单行注释的处理方式与基本 SAS 语言中的处理方式不同。具体来说:

*something;

不是SAS宏语言中的注释!它将被提交给常规 SAS,并将成为注释...但它不会被 SAS 宏解析器忽略,这就是问题所在。它对其进行标记,这导致它不会忽略引号字符。

您需要使用“PL/1”样式注释(即 block 注释)才能使其正常工作;或者只是不使用撇号(即,在注释中使用 do not 而不是 don)。

%macro testme;
/* Comment won't break things now!*/
proc freq data=sashelp.class;
run;

%mend testme;

%testme;

参见the SAS support article on Using Comments In Macros了解更多信息。

关于sas - 为什么我的宏中的报价不平衡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31839951/

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