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?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.