Hi:
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).
xxx:yy [/pre]
(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.
[pre]
format weight1 5.2;
format weight1 11.8;
format weight1 11.6;
format weight1 5.1;
[/pre]
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)
[pre]
format weight1 5.2;
[/pre]
or
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):
[pre]
somecalc = round(weight1,.01) * 4;
sillycalc = (round(weight1,.01) / height) * 14;
[/pre]
or
Do you want to keep WEIGHT1 as the original number, but make a second variable (WEIGHT2) that is STORED with 2 decimal places?
[pre]
weight2 = round(weight1,.01);
[/pre]
You might also want to read some Tech Support documents that talk about numeric precision:
http://support.sas.com/techsup/technote/ts654.pdf
http://support.sas.com/documentation/cdl/en/lrcon/59522/HTML/default/a000695157.htm
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.
cynthia