SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 5797|回复: 6
打印 上一主题 下一主题

SAS advance exam question 7: Macro Variables

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2010-7-7 11:52:36 | 只看该作者

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.

^_^
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2010-7-7 12:49:24 | 只看该作者

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.
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
板凳
 楼主| 发表于 2010-7-8 08:27:08 | 只看该作者

Re: SAS advance exam question 7: Macro Variables

是分号的问题,不加分号ACD都对
[code:3c6qqso9]%macro COLS1;
   Name Age
%mend;
%macro COLS2;
   Height Weight
%mend;[/code:3c6qqso9]
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
地板
 楼主| 发表于 2010-7-8 08:56:25 | 只看该作者

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!

^_^
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
5#
 楼主| 发表于 2010-7-8 09:01:50 | 只看该作者

Re: SAS advance exam question 7: Macro Variables

算日子你也该考完ADV了呀,还没去哪
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
6#
 楼主| 发表于 2010-7-8 11:54:51 | 只看该作者

Re: SAS advance exam question 7: Macro Variables

I will take the ADV exam on this Friday morning.
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
7#
 楼主| 发表于 2012-7-11 15:41:24 | 只看该作者

Re: SAS advance exam question 7: Macro Variables

这上题目我在考ADV的时候遇到过,当时是猜的。哎。。。。
经教师一指点,原来如此!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2025-5-6 09:30 , Processed in 0.075324 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表