So, I have re-read the original problem description, and I'm still not 100% sure I have the answer you are looking for, but I think this gets you close.
data WORK.IPNEW2;
retain age_non_blank;
infile datalines;
input id age NO2;
if not missing(age) then age_non_blank=age;
label id="IDCode" age="Mother's age at baseline";
datalines;
10001 32 47.813976991
10001 . 60.016236077
10001 . 53.004974541
10001 . 48.732284383
10002 36 55.695500415
10002 . 43.528170487
;
proc transpose data=ipnew2 out=ipnew2_t prefix=pollution_;
by id age_non_blank;
var no2;
run;
... View more