Hello,
Below is the program. When I apply format to max it works perfectly as expected, but I was trying to use input statement and the results did not look right at all. One of my colleagues also suggested I can re-write it as max1= input(put((n1/n2),4.1),best.); but I still did not understand why input is converting numeric values to character in the first place. Any help?
data dryrun;
input n1 n2;
max = n1/n2;
max1= input((n1/n2),4.1);
format max 4.1;
datalines;
37 53
40 52
39 52
;
run;
The input function requires a character value. So when you feed it a numeric value it converts it into a character value, usually using some form of BEST format. Then "inputs" the result.
The question is why would you even attempt an input of such a thing? What do you expect to result?
Generally the approach would be to do a numeric calculation and round the result if you don't want more than one decimal.
Perhaps
max = round( n1/n2, 0.1);
Or show us the explicit result you are expecting/wanting.
The input function requires a character value. So when you feed it a numeric value it converts it into a character value, usually using some form of BEST format. Then "inputs" the result.
The question is why would you even attempt an input of such a thing? What do you expect to result?
Generally the approach would be to do a numeric calculation and round the result if you don't want more than one decimal.
Perhaps
max = round( n1/n2, 0.1);
Or show us the explicit result you are expecting/wanting.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.