ID in the data set must be in the sorted order.
Collect the distinct Condition into a String sufficiently spaced (STR here) in one DoW loop.
Match the Condition in STR to determine its Order in it and write out the observation in the second DoW loop.
data Have;
input ID :$3. Condition :$2. Year;
datalines;
ID1 ZZ 2005
ID1 XX 2006
ID1 XX 2007
ID1 ZZ 2008
ID1 ZZ 2009
ID1 YY 2010
ID2 BB 2006
ID2 BB 2007
ID2 AA 2008
ID2 AA 2009
ID2 CC 2010
;
run;
proc sort data = have;
by id;
run;
data want;
length str $32767;
do until(last.id);
set have;
by id;
if find(str,Condition) = 0 then str = catx(' ', str, Condition);
end;
do until(last.id);
set have;
by id;
want = findw(str, Condition, ' ', 'E');
output;
end;
run;