INPUT function expect text values so control the conversion to text of your existing numeric value with the PUT function and an appropriate format.
The -L option with the Put function left justifies the value so there are not leading spaces which might confuse your informat.
data want;
set have;
inj_vol=input(put(weight,best8. -L), vol3_.);
run;
OR create a Format and INPUT the formatted value.
inj_vol = input (put(weight,yourvolfmt. -L),8.);
You want to be very cautious about ranges of character values, which the Informat actually stores for the start and end values. Note that your informat will treat a value like 40.8999999 as if it is 40.8 because of the rules for comparing character values.
You may want to specify an OTHER option in the value ranges with the _error_ assignment to create notes in the log about unexpected values.
Example, note the added row of data in the Have with the value of 3000.
data have;
input id weight @;
datalines;
1008 31.2
1009 47.8
1010 57.5
1011 95.5
1012 106.1
1013 110.0
1014 125.8
1015 166.3
1016 3000
;
run;
proc format library=work cntlout=work.cntlout;
invalue vol3_
30.0 - 40.8 = 0.2
40.9 - 57.4 = 0.3
57.5 - 74.1 = 0.4
74.2 - 90.8 = 0.5
90.9 - 107.4 = 0.6
107.5 - 124.1 = 0.7
124.2 - 140.8 = 0.8
140.9 - 157.4 = 0.9
157.5 - 174.1 = 1.0
174.2 - 180.0 = 1.1
other = _error_
;
run;
data want;
set have;
inj_vol=input(put(weight,best8. -L), vol3_.);
run;
... View more