为什么我的宏中的代码没有被考虑在内? [英] Why does my code inside my macro is not taken into account?

查看:47
本文介绍了为什么我的宏中的代码没有被考虑在内?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 SAS 上编写一个宏,该宏能够创建 1500 人的 50 个不同样本.但是一旦我输入%macro,以下所有代码都没有正确考虑(PROC SURVEYSELECT, DATA, RUN...不再有任何颜色).你会在我的代码下面找到,你能看看吗?

I'm trying to code a macro on SAS that is able to create 50 different sample of 1500 people. But as soon as I enter %macro, all the following code is not taken into account properly (PROC SURVEYSELECT, DATA, RUN... Do not have any color anymore). You'll find below my code, can you please have a look?

%macro loop(50);
%do i=1 %to 50;
    PROC SURVEYSELECT DATA=WORK.TOP_1()
        METHOD=SRS
        OUT= WORK.ALEA_1
        N=1500;
    RUN;
%end;
%mend;
%loop(50);

推荐答案

这只是增强型编辑器窗口的通常行为.

This is just the usual behaviour of the Enhanced Editor window.

您应该会发现,当您调用宏时,代码运行正常,但在宏定义中没有应用高亮显示.

You should find that when you call your macro the code runs properly, but highlighting isn't applied within the macro definition.

一种解决方法是在宏定义的开头,%macro 语句之后的行添加以下内容:

One workaround is to add the following at the start of your macro definition, on the line after the %macro statement:

%local DUMMY;
%let DUMMY = %nrstr(%mend);

这会欺骗编辑器认为它已经到达宏定义的末尾,而实际上对宏内部的代码没有任何影响,从而导致高亮显示被恢复.

This will trick the editor into thinking that it has reached the end of the macro definition without actually having any impact on the code inside the macro, resulting in the highlighting being restored.

这篇关于为什么我的宏中的代码没有被考虑在内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆