Create the data cast macro function