data test; infile "e:dataattachdd6429cm.wave1" length=len; length junk $ 1 varname $ 8 x $ 80; input x $varying. len @; if substr(x,1,1) = "D" then do; input @1 junk varname varlen varpos1 ; varpos2 = varpos1 + varlen - 1; output; end; else do; input ; end; run; proc print data=test; var varname varpos1 varpos2 ; run; data _null_; file "d:tempsasprog.txt" ; set test end=lastobs; if _n_ = 1 then put "input " ; put " " varname " " varpos1 "-" varpos2 ; if lastobs then put ";" ; run;