pick up on Cynthia's solution and make the infile parsing work a little harder for you 😉
The DLM= option of the INFILE statement can accept a variable name as well as a constant. Each time an INPUT statement is executed from the file defined by that INFILE, the value of the DLM= variable is re-evaluated to prepare for parsing. So, for reading the ID variables, set the delimiter to dash (-) and then set it to blank to read the remains of the line. Once the whole line is read, loop over the ID variables to release an observation for each non-blank ID :[pre]data reduced( keep= ID Var2 Var3 ) ;
length id i1-i8 $11 Var2 6 Var3 $40 delimiter $1 ;
attrib var2 format= mmddyy10. informat= mmddyy10. ;
infile cards dsd dlm=delimiter column=c ;
delimiter = '-' ;
input i1-i8 @;
delimiter = ' ' ;
input +1 /* pass over the first blank*/
Var2 @ ;
Var3 = substr( _infile_, c ) ; *put rest of line into Var3 ;
array i(8) ;
do c=1 to 8 ;
if i(c) =' ' then continue ;
id = i(c) ;
output ;
end ;
list;cards;
AB6772-CD5885-ABCD6194-XY7199---- 09/14/2010 London
PQ5928-SP352-BZ5752----- 09/16/2010 New York
;[/pre]
great things available in data step INFILE and INPUT parsing
enjoy
peterC
... View more