| proc sql noprint; create table ds as select * from all (keep=_NAME_ Col1-Col17 mom1)                                                                Comment: here is col1-col17, but when the "concyear" and concmonth changes, it   inner join b                                                                                                                                                               changes,too on all.mom1=b.mom   where b.month=2 and b.cyear=1987;                                                                                       Comment: I have from 02/1987 to 12/2013, that's why I need easier way.   quit; 
 
 data ds1; set ds; array col{3} col15-col17;                                                                                                              Comment: I only need 3 columns here. But now is 1987/02, if it is 1987/03, then I need array post{3} post1-post3;                                                                                                            col16-col18, etc. do i=1 to dim(col);       post(i) = col(i);    end;    run; 
    data ds2;    set ds1; array col{10} col5-col14;                                                                                                                Comment: I need 10 columns totally here. now is col5-col14, if it is 1987/03, then it is array g{10} g1-g10;                                                                                                                        col6-col15, etc. do i=1 to dim(col);       g(i) = col(i);    end; run; 
 data ds3;                                                                                                                                      Comment: Actually I need 24 columns as maximum, but here I have already reached set ds2; array col{4} col1-col4;                                                                                                                   minimum, it will increase as the date increase. For example, 1987/03 will have col1-col5, array pc{4} pc1-pc4;                                                                                                                    1987/04 will have col1-col6. When it reaches 24 column as col1-col24, the next month will do i=1 to dim(col);                                                                                                                         match col2-col25, and the count of column doesn't change any more       pc(i) = col(i);    end; run; 
 data ds; set ds3; drop col1-col17 i;                                                                                                                         drop total number of the old "col" name run; 
 |