Note that these format definitions
value $bmifmt 25-HIGH ="overweight" LOW -< 25="normal";
value $bmigrp LOW -< 18= 'underweight' 18 - 25 = 'normal' 25 <- HIGH = 'normal';
Are almost certainly not going to work if you use them with a character variable and cannot be used with numeric variables.
And did you INTEND to have "25<- HIGH= 'normal' " for BMIGRP??? likely should be 'overweight' or some such.
The range keywords LOW and HIGH are only really meaningful with numeric variables and ranges with character variables are pretty problematic at best and quite often do not yield expected results.
Why would any variable related to BMI be character in the first place??? If you want to use those ranges make sure BMI is numeric and define the format as such.
Example of very problematic of those character formats.
proc format;
value $bmifmt 25-HIGH ="overweight" LOW -< 25="normal";
value $bmigrp LOW -< 18= 'underweight' 18 - 25 = 'normal' 25 <- HIGH = 'overweight';
;
data example;
input bmi $;
Put bmi= "with $bmifmt " bmi=$bmifmt. "with $bmigrp " bmi1=$bmigrp. ;
datalines;
2
3
;
which yields:
512 data example;
513 input bmi $;
514 Put bmi= "with $bmifmt " bmi=$bmifmt. "with $bmigrp " bmi=$bmigrp. ;
515 datalines;
bmi=2 with $bmifmt bmi=normal with $bmigrp bmi=normal
bmi=3 with $bmifmt bmi=overweight with $bmigrp bmi=overweight
3 (as would 4, 5, 6 ... 9) are "overweight" because when character comparisons are performed they are done character by character until the shorter one runs out. So 3 is compared to the 2 in 25 and is "greater" so is in the "range" 25-HIGH and gets assigned to "Overweight" for BMIFMT and similar for BMIGRP.
Similar behavior with 2 with BMIGRP. 2 is larger than the 1 in the Low- 18 group, so is not set there but is "less than or equal" to 25 (actually "equal" to 25 as only compared to the 2) so gets assigned "normal" .