Creating a variable Based on molecule number

Hello,

I have a question I would like to create a variable of type vector that stores the x_coordinate of different atoms in molecular chains. For example, If i have 4 molecular chains
and i would like to store a vector of the x_coordinate of atoms in chain1 in a variable and x_coordinate of atoms in chain2 in a different variable and x_coordinate of atoms in chain3 in a different variable and so on. How can that be implemented in LAMMPS.

Thanks