I am trying to create an additional column called CALC which essentially condenses CalcHT, CalcWT and CalcBMI into one column. This is done by finding the corresponding variable and height, weight, hdcirc, bmi. Some data is missing. data have; input Variable $ Visit $ CalcHT CalcWT CalcBMI; cards;
Height 1 5 2 1
Weight 1 5 2 1
HDCIRC 1 5 2 1
BMI 1 5 2 1
Height 2 5 3 3
Weight 2 5 3 3
HDCIRC 2 5 3 3
BMI 2 5 3 3 ; data want;
input Variable $ Visit $ CalcHT CalcWT CalcBMI Calc;
cards;
Height 1 5 2 1 5
Weight 1 5 2 1 2
HDCIRC1 5 2 1
BMI 1 5 2 1 1
Height 2 5 3 3 5
Weight 2 5 3 3 2
HDCIRC 2 5 3 3
BMI 2 5 3 3 3
; Variable Visit CalcHT CalcWT CalcBMI Calc
Height 1 5 2 1 5
Weight 1 5 2 1 2
HDCIRC 1 5 2 1
BMI 1 5 2 1 1
Height 2 5 3 3 5
Weight 2 5 3 3 2
HDCIRC 2 5 3 3
BMI 2 5 3 3 3
For visit 1, CalcHT is 5 therefore Calc = 5 for Height
For visit 1, CalcWT is 2 therefore Calc = 2 for Weight For visit 1, CalcBMI is 1 therefore Calc = 1 for BMI
For visit 2, CalcHT is 5 therefore Calc = 5 for Height For visit 2, CalcWT is 3 therefore Calc = 3 for Weight
so on and so forth. I'm not sure where to start, but I believe this would be the inverse of an array or a transpose.
... View more