proc sql;
select year,prov,
case
when prov like '%省%' THEN 1
WHEN prov LIKE '%市%' THEN 2
when prov like '%县%' then 3
else 0
end as type
from have;
quit;
data have;
input year prov :$20. id;
if substr(prov,(length(prov)-2),2)="省" then type="1";
if substr(prov,(length(prov)-2),2)="市" then type="2";
if substr(prov,(length(prov)-2),2)="县" then type="3";