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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: