data a;
do i=1 to 30;
flg1=1;
age_flg=int(i/4);
output;
end;
drop i;
run;
data b;
do i=1 to 20;
flg2=1;age_flg=int(i/4);
output;
end;
drop i;
run;
data c;
do i=1 to 10;
flg3=1;age_flg=int(i/4);
output;
end;
drop i;
run;
data all;
set a b c;
run;
data wk01;
set all; 
run;
proc sort data=ALl; by flg1 flg2 flg3;run;
proc freq data=ALL;
tables age_Flg/out=res01 nopercent;
by flg1 flg2 flg3;
run;
proc transpose data=res01 out=res01_TRAn prefix=col;
id age_flg;
var count;
by flg1 flg2 flg3;
run;
%Let end_Col=7;
data res02;
lengh col1-COl&End_col 8.;
set res01_tran;
run;
%macro make_tobs_var(shtnum);

data freq_&shtnum;
length _col1-_COl&End_col $200.;
set res02(where=(flg&shtnum=1));
array lst _col:;
array dt col1-col&ENd_col;
%do i=1 %to &end_col;
lst[&i]=strip(put(dt[&i],8.));
a=cats("tobs",put(&shtnum,z3.),"_",put(&i,8.));
%global tobs%sysfunc(putn(&shtnum,z3.))_&i;
call symputx(a,lst[&i]);
%end;

keep a _col:;
run;
%Mend;
%make_tobs_var(1);
%make_tobs_var(2);
%make_tobs_var(3);


data test;
set sashelp.vmacro;
run;