I have two datasets gender and stage and common variable called category.
But in the gender dataset this variable has got a format gender where as in the other dataset the same variale has different format called stage.
But when I am setting these two datasets, SAS takes format from the first dataset only and applies the same format for the values in the other dataset.
But I want to retain the formatted values in both datasets when I am concatenating two datasets. How can I achieve this?
If I understand well, you concatenate the two datasets with a SET statement. The common variable had different formats in the separate datasets, is that correct ?
You cannot have two formats on a single variable, depending on the observation. But what you can do is create a character variable, using a PUT statement that will apply the correct format depending on the origin of the observation.
Something like :[pre]
DATA work.concat ;
SET work.gender (IN = in_gender) work.stage (IN = in_stage) ;
IF in_gender THEN char_var = PUT(category, gender.) ;
ELSE char_var = PUT(category, stage.) ;