how to transform a variables to index?

how to transform a variables to index?