如果你想用函数做分段也可以,但是效率不如format,可以参考下面这个例子
proc fcmp outlib = work.func.test;
function what(startvalue);
if missing(startValue) then rc=.S;
else if startValue < 0 then rc=.Z;
else if startValue < 20 then rc=0;
else if startValue < 50 then rc=20;
else if startValue < 100 then rc=50;
else rc=100;
return(rc);
endsub;
run;
options cmplib = work.func;
data a;
do i = -1 to 100 by 10;
b = what(i);
output;
end;
run;
Jackywolf_2008 发表于 2009-9-28 13:10
如果你想用函数做分段也可以,但是效率不如format,可以参考下面这个例子
proc fcmp outlib = work.func.test;
function what(startvalue);
if missing(startValue) then rc=.S;
else if startValue < 0 then rc=.Z;
else if startValue < 20 then rc=0;
else if startValue < 50 then rc=20;
else if startValue < 100 then rc=50;
else rc=100;
return(rc);
endsub;
run;
options cmplib = work.func;
data a;
do i = -1 to 100 by 10;
b = what(i);
output;
end;
run;
Jackywolf_2008 发表于 2009-9-28 13:10
如果你想用函数做分段也可以,但是效率不如format,可以参考下面这个例子
proc fcmp outlib = work.func.test;
function what(startvalue);
if missing(startValue) then rc=.S;
else if startValue < 0 then rc=.Z;
else if startValue < 20 then rc=0;
else if startValue < 50 then rc=20;
else if startValue < 100 then rc=50;
else rc=100;
return(rc);
endsub;
run;
options cmplib = work.func;
data a;
do i = -1 to 100 by 10;
b = what(i);
output;
end;
run;