Hi, made some assumptions as to how your data looks. Solution also creates the variable as a real date. If you don't care about that and just want the variable name, use the second data step. data x; input id d200101-d200103; datalines; 1 1 . 1 2 . . 1 3 . 1 1 ; data y; format first1 yymon7.; set x; array d(*) d: ; first1 = input(substr(vname(d(whichn( 1,of d: ))),2,6),yymmn6.); run; Obs date id d200101 d200102 d200103 1 2001JAN 1 1 . 1 2 2001MAR 2 . . 1 3 2001FEB 3 . 1 1 Alternative, FIRST1 as a character variable (variable name with the first occurrence of a 1) ... data y; set x; array d(*) d: ; first1 = vname(d(whichn( 1,of d: ))); run;
... View more