SAS Helpful Hints
Biostat Macro Library
Break a long string into pieces <=120 characters for easier printing
%Macro mkcomm(oldlong,new,max);
*Create an array to recieve the cut string:
new1 new2 new3...;
%Let ccomments= ;
%Do ii=1 %To %Eval(&max);
%Let ccomments=&ccomments
&newⅈ
%End;
Array cm&new $ 120 &ccomments;
ii=1;
bbreak1=1;
ccomlen=Length(&oldlong);
Do While (ccomlen>ii*110+9+bbreak1);
*Find a space in the 110-120th positions in the long string;
bbreak2=Index(Substr(&oldlong,ii*110+bbreak1,10),' ');
*Cut the long string;
cm&new{ii}=Substr(&oldlong,(ii-1)*110+bbreak1,110+bbreak2);
bbreak1=bbreak1+bbreak2;
ii=ii+1;
End;
cm&new{ii}=Substr(&oldlong,(ii-1)*110+bbreak1,ccomlen-((ii-1)*110+bbreak1-1));
%Mend mkcomm;
Data work.B;
Set work.A;
%mkcomm(longstring,short,8);
Run;
Please send your comments and suggestions about this web page to A. Watts
(watts@bst.rochester.edu)
|