Generally, you use the INPUT function to convert a CHARACTER variable to a NUMERIC variable. If your WEIGHT1 var is numeric, then I'm surprised that you didn't report a NOTE
in the log like this:[pre]
NOTE: Numeric values have been converted to character
values at the places given by: (Line)Column).
(where the line:column numbers point to the line that contains the INPUT function.)
I would not use the INPUT function since WEIGHT1 is numeric. It's the wrong function.
A number can have great precision when stored, for calculation purposes -- but you might only want to display 2 decimal places, for report purposes.
You can assign a SAS Format on a procedure by procedure basis -- you want WEIGHT1 formatted as 5.2 for one proc print, but want it formatted as 11.6 for a different proc print.
OR you can have the format assigned permanently so that the default format would always be used for the display of the number.
Using a SAS Format to change the DISPLAY of the number doesn't change the internal STORAGE of the number.
format weight1 5.2;
format weight1 11.8;
format weight1 11.6;
format weight1 5.1;
These are all FORMAT statements that you could use with your procedures to change the DISPLAY of WEIGHT1.
Anyway back to the idea of storing a number with 2 decimal places versus displaying a number with 2 decimal places. The above statements only DISPLAY a number with 2 decimal places. They do nothing to adjust the decimal places for the internal storage of the number. But perhaps, you want to change weight1 so it's only STORED with 2 decimal places -- in which case, the ROUND or ROUNDZ functions might be what you want to use.
What is it that you're trying to do?
Do you want to just DISPLAY WEIGHT1 with 2 decimal places on reports?
(Use a FORMAT statement)
format weight1 5.2;
Do you want to use WEIGHT1 with 2 decimal places in calculations (instead of all 8 possible decimal places)?
(ROUND WEIGHT1 before you use it in the calc):
somecalc = round(weight1,.01) * 4;
sillycalc = (round(weight1,.01) / height) * 14;
Do you want to keep WEIGHT1 as the original number, but make a second variable (WEIGHT2) that is STORED with 2 decimal places?
weight2 = round(weight1,.01);
If you need more help figuring out what you want to do with your numbers, and/or need help figuring out whether your particular analysis would be affected by the number of decimal places, you might consider contacting Tech Support for more help. If all you want to do is change the DISPLAY of WEIGHT1 in a report, then a simple FORMAT statement should work for you.