Here is another way, writing to lst.
[pre]
/* test data */
data one;
input id : $ @@;
datalines;
200 201 202* 203 204* 205 206 207 208
209* 210 211 212 213 214 215* 216
;
run;
/* this assumes that id^s are conjecutive */
data _null_;
length start finish range $20 comma $1;
retain start finish comma "";
set one end=end;
star = index(id,"*") > 0;
if star then do;
if missing(start) then return;
link outRange;
call missing(start, finish);
end; else do;
if missing(start) then start = id;
finish = id;
end;
if end and not missing(start) then link outRange;
return;
outRange:
file print;
len = lengthn(comma);
put comma $varying. len @;
range = ifc(start=finish, start, catx("-", start, finish));
len = lengthn(range);
put range $varying. len @;
comma = ",";
return;
run;
/* on lst
200-201,203,205-208,210-214,216
*/
[/pre]