The reason your program is not working is that PESO must be a vector with the same number of elements as the BMI variable. There are two ways to do this:
1. Define a format and use the format to recode the BMI vector.
2. Use the BIN function in IML to classify each BMI value into a category.
The program below shows the second method:
proc iml;
tClass=TableCreateFromDataSet ("Sashelp", "Class");
*call TablePrint(tClass);
Y=TableGetVarData (tClass, {"Weight" "Height"});
wt=Y[,1];
ht=Y[,2];
BMI=wt/ht##2 * 703;
/* allocate vector that is the same length as the data */
catIdx = bin(BMI, cutpts);
/* set up cut points */
category = {'Abaixo do Peso' 'Normal' 'Sobrepeso' 'Obesidade' 'Obesidade Grave'};
cutpts = {.M 18.5 25 30 40 .I};
PESO = category[ catIdx ];
call TableAddVar(tClass, "BMI", BMI);
call TableAddVar(tClass, "PESO", PESO);
call TablePrint(tClass);
... View more