BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

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;
4 REPLIES 4
FreelanceReinh
Jade | Level 19

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;
PaigeMiller
Diamond | Level 26

@FreelanceReinh you typed 0.5 several times, did you mean to type 0.05?

--
Paige Miller
FreelanceReinh
Jade | Level 19

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

PaigeMiller
Diamond | Level 26

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

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 843 views
  • 3 likes
  • 3 in conversation