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").
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.