Well, it doesn't make sense, as all the ranges are the same? Maybe it is the val part I am missing? Anyways some code towards what you want:
data std;
input age percentile $ val ht;
datalines;
1 n1 45 50.5
1 n2 55 50.5
1 n3 65 50.5
1 n4 75 50.5
1 n5 85 50.5
1 n1 49 55.8
1 n2 54 55.8
1 n3 66 55.8
1 n4 75 55.8
1 n5 88 55.8
;
run;
proc sort data=std;
by age percentile ht;
run;
data std_upd (keep=age percentile lower higher);
set std;
by age percentile;
retain lower higher;
if first.percentile then lower=ht;
if last.percentile then do;
higher=ht;
output;
end;
run;
data subj;
input id $ ht val age;
datalines;
xyz 52 50 1
abc 56 71 1
;
run;
proc sql;
create table want as
select a.*,
b.percentile,
b.lower,
b.higher
from subj a
left join std_upd b
on a.age=b.age
and b.lower <= a.ht <= b.higher;
quit;
... View more