Dear
Please suggest me to update below pgm to output one sided p value into sas dataset. Thank you
data one;
input id stra$ aval avalc$;
datalines;
1 a 1 cr
2 a 1 cr
3 a 1 cr
4 a 1 cr
5 a 2 cri
6 a 2 cri
7 a 2 cri
8 a 2 cri
9 a 1 cr
10 a 1 cr
;
ods trace on;
ods output onewayfreqs=stat binomialcls=cl;
proc freq data=one;
by stra;
tables aval/binomial(exact) alpha=0.05;
run;
Hello @knveraraju91,
You can either extend the ODS OUTPUT statement or add an OUTPUT statement to the PROC FREQ step.
If you mean the p-value of the approximate one-sided test of H0: p=0.5, which is contained in your printed output,
One-sided Pr > Z 0.2635
use
ods output onewayfreqs=stat binomialcls=cl binomialtest=want(where=(name1='PR_BIN'));
(then the p-value is in variable nValue1 of dataset WANT)
or add this statement to the PROC FREQ step:
output out=want binomial;
(then the p-value is in variable PR_BIN of dataset WANT; you can add a KEEP= dataset option after "want" to select only variables of interest).
If you mean the p-value of the exact one-sided test of H0: p=0.5, which is currently not contained in your printed output, add this EXACT statement to the PROC FREQ step:
exact binomial;
and, again, use either of the above techniques to write the p-value
Exact Test One-sided Pr >= P 0.3770
to a dataset. But the name is now XPR_BIN, i.e.,
ods output onewayfreqs=stat binomialcls=cl binomialtest=want(where=(name1='XPR_BIN'));
or see variable XPR_BIN in the dataset created by the OUTPUT statement:
proc freq data=one; by stra; tables aval/binomial(exact) alpha=0.05; exact binomial; output out=want binomial; run;
@FreelanceReinh you typed 0.5 several times, did you mean to type 0.05?
@PaigeMiller wrote:
@FreelanceReinh you typed 0.5 several times, did you mean to type 0.05?
No, I didn't mean 0.05. The default null proportion is 0.5 (see P= sub-option of the BINOMIAL option of the TABLES statement).
If you want a one-sided test at alpha = 0.05, this is the same limit as a two-sided test at alpha = 0.025
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.