SAS中文论坛

标题: two questions about macro variables [打印本页]

作者: shiyiming    时间: 2008-10-17 09:50
标题: 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.
作者: shiyiming    时间: 2008-10-18 12:08
标题: 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 -->
作者: shiyiming    时间: 2008-10-19 20:35
标题: 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
作者: shiyiming    时间: 2008-10-20 20:13
标题: Re: two questions about macro variables
问题一,就是g=var_name,在data步里面,当然会出现两个变量g 和var_name.
问题而,显而易见




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