a******p 发帖数: 414 | 1 下面是我的code:
data new;
set old end=last;
retain total;
if _n_=1 then all=0;
call symput(trt,compress(count));
all=all+count;
if last then call symput('all', compress(all));
run;
这里trt 是treatment,有四个值。
我想请问,call symput(trt,compress(count)); 不能用在macro中么?只能用在data
step?
下面是我想要的。
%macro count(data=,var=);
data new;
set old end=last;
retain total;
if _n_=1 then all=0;
call symput(trt,compress(count));
all=all+count;
if last then call symput('all', compress(all));
run;
%mend;
非常感谢! | f*******n 发帖数: 2665 | 2 不需要放入宏中。
call symput( 'trt'||put(trt,1.),.......
【在 a******p 的大作中提到】 : 下面是我的code: : data new; : set old end=last; : retain total; : if _n_=1 then all=0; : call symput(trt,compress(count)); : all=all+count; : if last then call symput('all', compress(all)); : run; : 这里trt 是treatment,有四个值。
| a******p 发帖数: 414 | 3 非常感谢你的回答。但我的这段code是在一个大的宏里面。
【在 f*******n 的大作中提到】 : 不需要放入宏中。 : call symput( 'trt'||put(trt,1.),.......
| P****D 发帖数: 11146 | 4 你写的逻辑不对罢了。一个宏变量只能有一个值。例如你要count的第一个值成为宏变
量trt,那就 if _n_=1 then do; call symput('trt', compress(count)); end; | a******p 发帖数: 414 | 5 下面是我的code:
data new;
set old end=last;
retain total;
if _n_=1 then all=0;
call symput(trt,compress(count));
all=all+count;
if last then call symput('all', compress(all));
run;
这里trt 是treatment,有四个值。
我想请问,call symput(trt,compress(count)); 不能用在macro中么?只能用在data
step?
下面是我想要的。
%macro count(data=,var=);
data new;
set old end=last;
retain total;
if _n_=1 then all=0;
call symput(trt,compress(count));
all=all+count;
if last then call symput('all', compress(all));
run;
%mend;
非常感谢! | f*******n 发帖数: 2665 | 6 不需要放入宏中。
call symput( 'trt'||put(trt,1.),.......
【在 a******p 的大作中提到】 : 下面是我的code: : data new; : set old end=last; : retain total; : if _n_=1 then all=0; : call symput(trt,compress(count)); : all=all+count; : if last then call symput('all', compress(all)); : run; : 这里trt 是treatment,有四个值。
| a******p 发帖数: 414 | 7 非常感谢你的回答。但我的这段code是在一个大的宏里面。
【在 f*******n 的大作中提到】 : 不需要放入宏中。 : call symput( 'trt'||put(trt,1.),.......
| P****D 发帖数: 11146 | 8 你写的逻辑不对罢了。一个宏变量只能有一个值。例如你要count的第一个值成为宏变
量trt,那就 if _n_=1 then do; call symput('trt', compress(count)); end; | a******p 发帖数: 414 | 9 谢谢你的回复,但我没有写错。
如果我这样写,其中 trt 是变量,取值例如 placebo, active1, active 2,
call symput(trt, compress(count))
那么我是可以生成三个宏变量的: &placebo, &active1,&active2
如果加上引号call symput('trt', compress(count));
那么只能生产一个宏变量
【在 P****D 的大作中提到】 : 你写的逻辑不对罢了。一个宏变量只能有一个值。例如你要count的第一个值成为宏变 : 量trt,那就 if _n_=1 then do; call symput('trt', compress(count)); end;
|
|