10-23-2015 03:31 PM
Are you looking for the calculation 45-74 or a character value "45-74"? Is Number currenlty numeric or character?
What if there are 3 or more records with the same value of Id?
10-23-2015 03:34 PM
Sorry it wasnot clear. I updated tables. It is character values not calculation. And yes if i have more than 2 it will be same like 12-15-17-13. Thank you
10-23-2015 04:50 PM
Here you go..
data in;infile datalines dlm='09'x;
input id:$2. num: $2.;
proc sort;by id;run;
data in(keep=id new_id rename=(new_id=num));
set in;by id;
length new_id $3000.;
length final_id $3000.;
if first.id then new_id = num; else new_id=left(trim(new_id))|| '-' || num;
if last.id then do;final_id=left(trim(new_id));output;end;
Hope this helps...!!!
10-23-2015 04:54 PM
Something like this maybe what you are looking for. You imply that the data is in order so I will assume it is sorted by the ID.
data want; set have; by id; length numcombined $ 50 ; /* this needs to be long enough to hold the longest combination plus the -*/ if first.id then numcombined=number; else numcombined = catx('-',numcombined,number); if last.id; run;