data sample;
input date $ number $14.;
cards;
20031101 75582368888
20031101 2082368887
20031102 2182368886
20031102 5236237888
;
run;
data temp;
set sample;
numlength= length(number);
if numlength = 10 then
do;
if substr(number,1,2)='20' then /*本例中只有2个这类城市,如果10个都包含的话,这一段程序会比较复杂*/
do;
area='Guangzhou';
end;
else if substr(number,1,2)='21' then
do;
area='Shanghai';
end;
else do;
area= substr(number,1,3);
end;
end;
if numlength = 11 then area= substr(number,1,3);
run;作者: shiyiming 时间: 2004-3-25 17:10
试试select/case语句,在HELP中可以查到用法的。