Here i Need a solution for below problem. i need output should be like 25.45 only that to be by using string functions.
data ex1 ;
mynumber=25.45789;
Why do you want to use only string functions?
So you have a character string and you just want to take the first 5 characters?
Use substr().
data have;
string='25.45789';
new_string=substr(string,1,5);
run;
If the actual request is not to just take the first 5 character then please explain the rule more completely.
Also why did you call the variable MYNUMBER if you want it to be a character variable?
So this task is meant to test your skills, not ours 😉
What is the actual rule? Take the first 5 characters, or reduce to 2 fractional digits, with or without rounding?
is mynumber numeric? if it's numeric, then you can do strip(put(mynumber,8.2)).
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.