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?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: