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)).
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 save with the early bird rate—just $795!
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.