I need to create a variable which combined three variables age
, sexe
and agios
. All of them are located in a sas table and all of them are numeric.
In first step, I transform them into categorical variables then I suggest to use the compress function to create this new variable:
data new;
set new;
attrib sexe format=$15.;
if sexe=1 then sexe="HOMME";
else if sexe=0 then sexe="FEMME";
attrib agios format=$15.;
if agios=0 then agios="NON_AGIOS";
else AGIOS="AGIOS";
attrib age format=$15.;
if (age<=0) and (age=>25) then age="a25";
if (age<=26) and (age=>40) then age="a40";
if (age<=41) and (age=>65) then age="a60";
if (age=>65) then age="a65";
new_variable=compress(agios||sexe||age);
run;
But I have an warnings repeted to all the concerned variables:
WARNING: Variable agios has already been defined as numeric.
And there wasn't any transformation for the variables in the table. Also, values of the concerned variables age
, sexe
and agios
disappear from the table. It begins empty.
How do I correct this please? Or is there any other suggestion to create the new variable without using ifelse?
Thank you