Why does my code inside my macro is not taken into account?

空扰寡人 提交于 2019-12-13 05:19:56

问题


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);

回答1:


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.

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.




回答2:


You don't need macro. If you want 50 samples use the SURVEYSELECT option REPS=50.



来源:https://stackoverflow.com/questions/49774548/why-does-my-code-inside-my-macro-is-not-taken-into-account

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!