data div;
input value $;
datalines;
40/20
150/30
300/100
;
run;
data dd;
set div;
result=mod(input(value,value,best12.));
proc print;
run;
How to divide values
It is not clear what you are trying to do.
What output would you expect from that input.
Also explain what real world situation would require that you do anything like this?
So convert the string into two pieces, convert the substrings into numbers, divide the numbers.
result = input(scan(value,1,'/'),32.) / input(scan(value,2,'/'),32.);
Reading from a raw file? Then use DLM='/' (assuming you always expect a division sign):
data want;
infile datalines dlm='/';
input numerator denominator;
quotient=numerator/denominator;
datalines;
40/20
150/30
300/100
run;
Maybe evaluate the expression to a numeric value and then continue from there:
data want;
set div;
nvalue=input(resolve(cats('%sysevalf(',value,')')),32.);
run;
KSharp used this RESOLVE-%SYSEVALF technique in several of his posts (e.g., here in 2011; in 2012 he mentioned that he himself learned it "from this Forum").
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.