Good afternoon fellow SAS users and the overall SAS community.
oba f se
1 7/30
2 5/30
3 9/30
4 11/30
5 21/30
SE=f*(1-f)/5,
How can use loop to operation all SE?
Thank you!!
Hope this is what you are expecting
data have;
input oba f$;
cards;
1 7/30
2 5/30
3 9/30
4 11/30
5 21/30
;
data want;
set have;
numerator=input(scan(f,1,'/'),best.);
denominator=input(scan(f,2,'/'),best.);
nd=numerator/denominator;
SE=nd*(1-nd)/5;
run;
Hope this is what you are expecting
data have;
input oba f$;
cards;
1 7/30
2 5/30
3 9/30
4 11/30
5 21/30
;
data want;
set have;
numerator=input(scan(f,1,'/'),best.);
denominator=input(scan(f,2,'/'),best.);
nd=numerator/denominator;
SE=nd*(1-nd)/5;
run;
For the values you have, @Tom 's reply is probably the best way.
For a generic calculation, here is another way:
data HAVE;
input OBA F $20.;
cards;
1 7/30+4/3
2 5/30
3 9/30
4 11/30
5 21/30-23/16+5/8
;
data WANT;
set HAVE;
F1=input(resolve('%sysevalf('||F||')'),32.); putlog F1= ;
SE=F1*(1-F1)/5;
run;
Do you actually have that "F" value as the strings you are showing? Or do you have two numeric variables?
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!
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.