SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 601|回复: 3
打印 上一主题 下一主题

two questions about macro variables

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2008-10-17 09:50:04 | 只看该作者

two questions about macro variables

First one:
program is as follow:

%let var_name=2;

data _null_;
call symput("c",&var_name);
call symput("e","var_name");
run;

data b;
d=&c;
f="&e";
g=&&e;
b=&var_name;
run;

Question: Why I can't resolve macro variable g?

Second one:

program:
%macro my_reg(indata=,  dep_var_list=, indep_var_list=);

         
    %if ("&var_name"="DP_CC_DM_APP"          and "&ind_var" in ("IN_PT_OP_LD","IN_RA_GA","IN_PT_OP_CH","IN_ME_OP_LD","IN_TV_OP_LD"))

      %then %do;
       proc reg data=&indata;
       model    &dep_var_list    =  &indep_var_list;
       run;

       %end;
   
%mend ;

Qeustion. Why I can't use in function here?

Thanks in advance.
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2008-10-18 12:08:44 | 只看该作者

Re: two questions about macro variables

#1
page 6 of <!-- m --><a class="postlink" href="http://ssc.utexas.edu/docs/sashelp/sugi/24/Handson/p149-24.pdf">http://ssc.utexas.edu/docs/sashelp/sugi ... 149-24.pdf</a><!-- m -->
#2
<!-- m --><a class="postlink" href="http://support.sas.com/kb/11/945.html">http://support.sas.com/kb/11/945.html</a><!-- m -->
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
板凳
 楼主| 发表于 2008-10-19 20:35:57 | 只看该作者

Re: two questions about macro variables

Thanks so much. For the second question, I see the example is as follow:

   %macro test;
     %let x = #ABC#;
     %if &amp;x = ABC %then %put Match;
     %else %put No Match;
         %put &quot;&amp;x&quot;;
   %mend test;
   %test

It still can't use IN function. If I use above sample code, it's no match. Why I need to use %quote. If I use the following code, it would be match.

   %macro test;
     %let x = #ABC#;
     %if &amp;x = #ABC# %then %put Match;
     %else %put No Match;
         %put &quot;&amp;x&quot;;
   %mend test;
   %test
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
地板
 楼主| 发表于 2008-10-20 20:13:57 | 只看该作者

Re: two questions about macro variables

问题一,就是g=var_name,在data步里面,当然会出现两个变量g 和var_name.
问题而,显而易见
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-5 03:26 , Processed in 0.067306 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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