SAS中文论坛

标题: SAS advance exam question 7: Macro Variables [打印本页]

作者: shiyiming    时间: 2010-7-7 11:52
标题: SAS advance exam question 7: Macro Variables
I am very confused about this Macro Variables question.


The following SAS program is submitted:

  %macro COLS1;
     Name Age;
  %mend;      

  %macro COLS2;
     Height Weight;     
  %mend;      

  proc print data=SASHELP.CLASS;
     [_insert_VAR_statement_here_]      
  run;


  Which VAR statement successfully completes  the program to produce a report containing  four variables?


     A. var %COLS1 %COLS2;     

     B. var %COLS1-%COLS2;     

     C. var %COLS1 Weight Height;      

     D. var Weight Height %COLS1;

I ran these SAS codes and found that D is correct. I am confused why C is not correct. It would be great if anyone would like to explain it a little bit.

^_^
作者: shiyiming    时间: 2010-7-7 12:49
标题: Re: SAS advance exam question 7: Macro Variables
After running the codes,

proc print data=SASHELP.CLASS;
var %COLS1 Weight Height;
run;

I found the error message from the log window.


13   proc print data=SASHELP.CLASS;
14   var %COLS1 Weight Height;
                ------
                180
ERROR 180-322: Statement is not valid or it is used out of proper order.
15   run;


Does it means that Macro can only after the variables in this case?

Thanks in advance.
作者: shiyiming    时间: 2010-7-8 08:27
标题: Re: SAS advance exam question 7: Macro Variables
是分号的问题,不加分号ACD都对
[code:3c6qqso9]%macro COLS1;
   Name Age
%mend;
%macro COLS2;
   Height Weight
%mend;[/code:3c6qqso9]
作者: shiyiming    时间: 2010-7-8 08:56
标题: Re: SAS advance exam question 7: Macro Variables
Yeah, it is the point that confused me. I ran the codes again, and found all options worked well just as your mentioned. Thanks millios!

^_^
作者: shiyiming    时间: 2010-7-8 09:01
标题: Re: SAS advance exam question 7: Macro Variables
算日子你也该考完ADV了呀,还没去哪
作者: shiyiming    时间: 2010-7-8 11:54
标题: Re: SAS advance exam question 7: Macro Variables
I will take the ADV exam on this Friday morning.
作者: shiyiming    时间: 2012-7-11 15:41
标题: Re: SAS advance exam question 7: Macro Variables
这上题目我在考ADV的时候遇到过,当时是猜的。哎。。。。
经教师一指点,原来如此!




欢迎光临 SAS中文论坛 (http://www.mysas.net/forum/) Powered by Discuz! X3.2