sorry my bad.. @hashman 😛 . Got what you wanted to say. I tweeked it a bit. I think this will work now data a(keep=s z); s="123456789"; %macro nums; c=length(s); c1=put(c,best.); call symput('p',c1); l=int(c/4); l1=put(l,best.); call symput('k',l1); %do i=1 %to &k.; %if &i.=1 %then %do; a&i.=substr(s,1,4); %end; %if &i. ne 1 %then %do; a&i.=substr(s,(&i.-1)*4+1,4); %end; %if &i.=&k. %then %do; %let m=%sysevalf(&k.+1,integer); %put &m.; a&m.=substr(s,(&i)*4+1); %end; %end; length z $%sysevalf(&p.+&m.,integer).; %do j=1 %to &m.; %if &j.=1 %then %do; z=a&j.; %end; %else %do; z=cats(z,"-",trim(a&j.)); %end; %end; %mend nums; %nums; run; Please let me know if this works 🙂
... View more