Hi:
There is an alternate solution -- but it requires the following to be true:
1) there is always 1 space between VAR1 (ID), VAR2 and VAR3 and
2) the last piece of ID -ALWAYS- ends in a number
If these are true, then you can parse out ID when you first read the input file, as shown in the code below, using the ANYDIGIT function.
cynthia
[pre]
data readdash;
length var1 $35 var2 8 var3 $32;
** This infile/input combination assumes that there is ALWAYS;
** at least 1 space between each variable in the input file.;
infile datalines dlm=' ' ;
input Var1 &$ Var2:mmddyy10. Var3 &$32.;
format var2 mmddyy10.;
** As long as ID -always- ends in a number,;
** search backwards from the end of VAR1 and find the last digit;
** in the VAR1 variable. With ANYDIGIT, if start is negative, the;
** search starts at the END of the string and goes to the right.;
** So the value of GOTNUM is the position of the digit before the ----.;
lg = length(var1)*-1;
gotnum = anydigit(var1,lg);
** could obs 3 happen in the data??;
if gotnum gt 0 then id = substr(var1,1,gotnum);
else if gotnum = 0 then id = var1;
return;
datalines;
AB6772-CD5885-ABCD6194-XY7199---- 09/14/2010 London
PQ5928-SP352-BZ5752----- 09/16/2010 New York
ZZzzzz-SPeee-YYaaaa----- 09/16/2010 Albuquerque
;;;;
run;
proc print data=readdash;
run;
[/pre]