Hi All,
Can anyone help me to exhibit the numeric value with 2 decimal points as below
10010 should be represented as 10010.00
Below some sample code for both a numerical and a character variable.
If your variable is of type character then we must first convert the string to an number using an input statement and then use a put statement with a numerical format to create a string as you want it in your character variable. The character variable must have a length long enough to hold the additional 3 characters (the dot and two digits).
data have;
input @1 myvar_num @1 myvar_char $;
datalines;
20010
20050
20070
20014
;
data want;
set have;
format myvar_num 16.2;
myvar_char=put(input(myvar_char,best32.),16.2 -l);
run;
proc print data=want;
run;
Apply an appropriate format
data _null_;
n = 10010;
put n = 8.2;
run;
I am not able to get the required out put.
I have the values as below
20010
20050
20070
20014
i need the below output.
20010.00
20050.00
20070.00
20014.00
Need a pgrm so that i can apply the same with minor changes.
See this for proof:
data want;
input number;
format number 8.2;
datalines;
20010
20050
20070
20014
;
proc print data=want noobs;
run;
Result:
number 20010.00 20050.00 20070.00 20014.00
If you have trouble with your application of this, please post the log.
Below some sample code for both a numerical and a character variable.
If your variable is of type character then we must first convert the string to an number using an input statement and then use a put statement with a numerical format to create a string as you want it in your character variable. The character variable must have a length long enough to hold the additional 3 characters (the dot and two digits).
data have;
input @1 myvar_num @1 myvar_char $;
datalines;
20010
20050
20070
20014
;
data want;
set have;
format myvar_num 16.2;
myvar_char=put(input(myvar_char,best32.),16.2 -l);
run;
proc print data=want;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.