options CRT memory=6; name gspd5; ? ? duplicate state tort vars 73 times (for each industry) ? original version 1/1994 ? updated to remove unavailable data files 6/2003 ? freq n; set ns = 24*52; ? amount of obs in states set nt = 3796*24; ? n of obs in big file (24*73*52) set it = 73*24; ? create the example variable, t1, as a combination ? of state id and year, so the output can be easily checked. smpl 1,ns; trend(per=24) year; trend obs; state = 1 + (obs-year)/24; t1 = state*100 + year; ?print t1 state year; smpl 1,nt; new=0; list torts t1; ? list of variables to duplicate dot torts; stack . ; rename new .; enddot; ?print t1; ? This proc is tricky, because the input variables ? are in state-year order, while ? the outputs are in state-industry-year order. proc stack orig ; local tmp x r73; smpl 1 ns; mform(nrow=24,ncol=52) tmp = orig; matran tmp tmp; unmake tmp x; mmake r73 x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x ; mform(nrow=52,ncol=it) r73; matran r73 r73; smpl 1,nt; unmake r73 new; endproc stack;