The question is: given a series of version number, how to pick the latest version code? For example, given "1.3.8", "1.23.2", "1.9.15", "2.1", "0.99.99", "2.0.5.89", how to pick the latest code? (it should be "2.1" here in the example). In SAS, we can easily split the version number into cells(use array) and then fill up each cell with 0(use format) to compare.
The code is like:
data a;
input a & $100.;
cards;
1.3.9
1.32.08
1.2.7
3.5.7.89
5
1.60.10
1.7
0.3
;
run;
proc print data=a;
run;
data b;
set a;
array a_split[*] a_1-a_10;
do i=1 to dim(a_split);
a_split[i]=scan(a,i,'.');
end;
run;
data b;
set b(drop=i);
format _numeric_ z10.;
run;
proc sort data=b;
by a_1--a_10;
run;
proc print data=b width=min;
run;
The final output is:
No comments:
Post a Comment