Hello,
How do i output the binomial test into a dataset?
Thank you!
%macro yesci (var= ,trt=, p= , out=);
proc freq data=mrg2;
where trt01pn in (&trt);
tables &var / binomial(p=&p level="Y") out=&out;
run;
%mend yesci;
%yesci (var=cat6, trt=2 , p=0.242, out=cat6_trt2 );
The generic skill is to use the ODS Trace option:
<dummy code>
ods trace on; proc whatever <options>; run; ods trace off;
Your log will show the names of the output objects.
Example you can run:
ods trace on; proc freq data=sashelp.class; tables sex / binomial; run; ods trace off;
The log shows:
Output Added: ------------- Name: OneWayFreqs Label: One-Way Frequencies Template: Base.Freq.OneWayFreqs Path: Freq.Table1.OneWayFreqs ------------- Output Added: ------------- Name: Binomial Label: Binomial Proportion Template: Base.Freq.BinomialStatFactoid Path: Freq.Table1.Binomial ------------- Output Added: ------------- Name: BinomialTest Label: Binomial Proportion Test Template: Base.Freq.BinomialStatFactoid Path: Freq.Table1.BinomialTest -------------
You would use the bit(s) with the Name: in and ODS OUTPUT statement with <name>=<your data set name> pairs for the desired objects:
ods output BinomialTest= mybinomialtestdataset; proc freq data=sashelp.class; tables sex / binomial; run;
OR read the online help for the procedure. The Details section should have an ODS TABLE NAMES section that will have the name of the table (i.e. BinomialTest) and the option(s) required to create it.
The generic skill is to use the ODS Trace option:
<dummy code>
ods trace on; proc whatever <options>; run; ods trace off;
Your log will show the names of the output objects.
Example you can run:
ods trace on; proc freq data=sashelp.class; tables sex / binomial; run; ods trace off;
The log shows:
Output Added: ------------- Name: OneWayFreqs Label: One-Way Frequencies Template: Base.Freq.OneWayFreqs Path: Freq.Table1.OneWayFreqs ------------- Output Added: ------------- Name: Binomial Label: Binomial Proportion Template: Base.Freq.BinomialStatFactoid Path: Freq.Table1.Binomial ------------- Output Added: ------------- Name: BinomialTest Label: Binomial Proportion Test Template: Base.Freq.BinomialStatFactoid Path: Freq.Table1.BinomialTest -------------
You would use the bit(s) with the Name: in and ODS OUTPUT statement with <name>=<your data set name> pairs for the desired objects:
ods output BinomialTest= mybinomialtestdataset; proc freq data=sashelp.class; tables sex / binomial; run;
OR read the online help for the procedure. The Details section should have an ODS TABLE NAMES section that will have the name of the table (i.e. BinomialTest) and the option(s) required to create it.
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.