Hello, I am trying to create a new categorical variable and a new binary variable based off a series of binary variables that I have previously constructed, but the observation numbers are not adding up and I cannot find a solution. An example of the code I am using looks like this: Data newdata; Set oldata; If BV1 = 1 then CV = 1; If BV2 = 1 then CV = 2; If BV3 = 1 then CV = 3; Run; The number of observations where BV1 = 1 is 1165, the number of observations where BV2 = 1 is 69, and The number of observations where BV1 = 1 is 17. When I run the above code, the number of observations for each level of the categorical variable are less than the original numbers of the binary variables. I do not understand why these numbers would be changing. The construction of these binary variables were each based on their own variable, so there is no overlap of conditions for each of the binary variables I created. I noticed the same issue if I tried to create a new binary variable indicating positivity for any of the original binary variables I constructed. I have tried code using else if and or statements as follows: Data newdata; set oldata; If BV1 = 1 then NBV = 1; Else if BV2 = 1 then NBV = 1; Else if BV3 = 1 then NBV = 1; Run; Data newdata; set oldata; If BV1 = 1 or if BV2 = 1 or BV3 = 1 then NBV = 1; Run;
... View more