因为工作中很多涉及到了年龄分组的计算,我自己写了一个希望以后用起来方便一点,但是在其中宏参数设置中出现了点问题,就是我希望 do i=&min to &max by &h,1;中的1也能用宏参数表示(有时候小年龄分组要细化一下,不是5岁一组),但是
如果这样写的话,不需要小年龄组细分的时候就出问题了,那个逗号去不掉,运行不了,希望大家能帮助我一下,PS:我初学,程序写的不好,也希望指出,也多多学习,谢谢
%macro ageid(max,h,data,min=0,f=);
data a;
do i=&min to &max by &h,&f;
output;
end;
run;
proc sort data=a;
by i;
run;
data a;
set a end=last;
j=lag(i);
if last then i=1000;
if i=&min then delete;
run;
data _null_;
set a end=last;
call symput("qian"||left(trim(_n_)),j);
call symput("hou"||left(trim(_n_)),i);
if last then call symput("num",_n_);
run;
%put _user_;
%do i=1 %to #
data age;
set &data;
if &&qian&num<=age<&&hou&num then ageid="&&qian&num.-";
run;
%end;
%mend;