I would like to add two numerical variables together to create a new variable in SAS. However, if one of the variables is missing, SAS treats the entire observation is missing, even if the other variable has a value.
My code currently looks like this:
DATA FINAL.NEW_DATA;
SET FINAL.FULL_DATA;
FV_QTY = NUT_VEG_QTY NUT_FRUITS_QTY; *new continuous variable;
RUN;
How can I get SAS to still include the observations from one variable, even if the other is missing?
CodePudding user response:
Using the SUM Function instead. The Sum Function returns the sum of non-missing arguments.
DATA FINAL.NEW_DATA;
SET FINAL.FULL_DATA;
FV_QTY = sum(NUT_VEG_QTY, NUT_FRUITS_QTY);
RUN;