If you have a similar file, but with (say) the series names as CPI_cityname, then you would alter that to
compute cpilist=%slike("CPI_*")
and
ewise cpiroot(i)=slabel=%l(cpilist(i)),%mid(slabel,5,-1)
(%mid with a negative for the number of characters takes everything from position 5 to the end).
Code: Select all
cal(a) 1970:1
all 2011:1
*
open data general0.rat
data(format=rats) 1970:1 2011:1
compute cpilist=%slike("*0")
dec vect[label] cpiroot(%size(cpilist))
ewise cpiroot(i)=slabel=%l(cpilist(i)),%left(slabel,%strlen(slabel)-1)
disp cpiroot