DATA Step, Macro, Functions and more

Record from visit ordered by date

Reply
Super Contributor
Posts: 647

Record from visit ordered by date

 

SubjectIDTest_NameDateCollection_TimeResult_ValueResult_Units
123456Height6/8/2010NA1.53m
123456Height6/22/2010NA1.51m
123456HeightNANA1.51m
123456Weight6/8/2010NA63kg
123456Weight6/22/2010NA62kg
123456WeightNANA61kg
123456WeightNANA61kg
456789Height8/12/2010NA1.36m
456789HeightNANA1.36m
456789Height7/30/2010NA1.36m
456789Weight8/12/2010NA36kg
456789WeightNANA36kg
456789Weight7/30/2010NA36kg

 

Now if height is missing in all visits, then BMI is blank
if height is missing in one of the visits, take height from previous visits(from the last visit ordered by visit date)
if weight is missing in one of the visits, leave BMI blank

 

 

Trusted Advisor
Posts: 1,603

Re: Record from visit ordered by date

BMI is not present in this data set. Please explain further what you want to do and provide lots of details so we can understand your problem.

Super Contributor
Posts: 647

Re: Record from visit ordered by date

need to derive BMI. using below formula

BMI = Weight/(Height * Height)

Contributor
Posts: 56

Re: Record from visit ordered by date

data want(drop=new_bmi_height);
set have;
by subjectid date; retain bmi new_bmi_height;
if first.subjectid then do; bmi=0; new_bmi_height=0; end;
if missing(result_value) then
do;
if upper(test_name) eq 'HEIGHT' then bmi=new_bmi_height;
else if upper(test_name) eq 'WEIGHT' then bmi=0;
end;
else
do;
if upper(test_name) eq 'HEIGHT' then
do; bmi=/*Calculate BMI Value */; new_bmi_height=bmi; end;
else if upper(test_name) eq 'WEIGHT' then bmi=result_value;
end;
output;
run;
Super Contributor
Posts: 647

Re: Record from visit ordered by date

result_value is not BMI. it is actually weight and height values

Contributor
Posts: 56

Re: Record from visit ordered by date

You can upgrade easily how do you wish.
Ask a Question
Discussion stats
  • 5 replies
  • 116 views
  • 0 likes
  • 3 in conversation