SAS中文论坛

标题: 请高手帮忙!谢谢! [打印本页]

作者: shiyiming    时间: 2004-10-5 19:15
标题: 请高手帮忙!谢谢!
data aa;
input x y@@;
cards;
1        0
2        0
3        0
4        0
5        0
5.5        0
6        1
7        1
8        1
9        1
10        1
11        1
;
proc logistic desc;
model y=x;
run;
我想把5.5依次替换成6.0,6.05,6.10,6.15,6.20,8.0,用宏可以实现吗?
请求帮助!谢谢!
作者: shiyiming    时间: 2004-10-6 00:47
标题: try it.
Of course it can be solved with macro. like codes below.

data aa;
input x y@@;
cards;
1 0
2 0
3 0
4 0
5 0
5.5 0
6 1
7 1
8 1
9 1
10 1
11 1
;
run;
%macro logst;
%let val=6.0/6.05/6.10/6.15/6.20/8.0;
%do i=1 %to 6;
%let value=%scan(&val,&i,'/');
title "result for values of &value. for variable x.";
%put &value;
data bb;
  set aa;
  if x=5.5 then x=&value;
run;
proc logistic desc;
model y=x;
run;
quit;
%end;
title;
%mend;
%logst;

hope it can helps.
作者: shiyiming    时间: 2004-10-6 09:58
标题: 谢谢
谢谢!
是否可以再简单一些!
作者: shiyiming    时间: 2004-10-23 12:23
标题: re
可以用array做。
%macro test;

%let numtorplace=6;

%do j =1 %to &numtorplace;
data bb&j;
set aa;
array  replace{&numtorplace} (6.0,6.05,6.10,6.15,6.20,8.0);  
if x=5.5 then x = replace(&j);  
drop replace1-replace8;
run;
%end;
%mend test;
%test;
作者: shiyiming    时间: 2004-10-23 14:17
标题: 出错
有误!运行出错!
作者: shiyiming    时间: 2004-10-24 23:20
标题: re
给你的只是data step。你要用proc要把它放在macro里面。你想要的macro应该是:

data aa;
input x y@@;
cards;
1 0
2 0
3 0
4 0
5 0
5.5 0
6 1
7 1
8 1
9 1
10 1
11 1
;

%macro test;

%let numtorplace=6;

%do j =1 %to &numtorplace;
data bb&j;
set aa;
array  replace{&numtorplace} (6.0,6.05,6.10,6.15,6.20,8.0);  
if x=5.5 then x = replace(&j);  
drop i replace1-replace8;
run;

proc logistic desc;
model y=x;
run;

%end;
%mend test;
%test;




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