简体   繁体   中英

SAS only include chi-square output in proc freq

I'm using the following code to do a chi-square test in SAS.

proc freq data=data;
tables var1*var2/chisq;
run;

It gives the output of both chi-square and Fisher's Test. Anyway to only include chi-square test in the output? 在此处输入图像描述

You can use ODS SELECT/EXCLUDE to control what is displayed. If you don't want the fishers test you can exclude that table, assuming the table name is FISHERSEXACT.

ods exclude fishersexact; 

Alternatively you can select in only the tables you want and everything else is excluded by default.

ods select crosstabfreqs chisquare;

I do not think you can supress printing some of the tables in PROC FREQ; it seems to me you can supress all, or none.

However, still you can work as follows:

  1. First, do a one-off investigation: issue the ods trace on / label before your statement so that the Log contains labels of the ODS tables:
ods trace on / label;
proc freq data=data;
tables var1*var2/chisq;
run;
ods trace off;

Alternatively, find the name of your table in PROC FREQ docs .

  1. Once you know the table name, run your code again but this time save the respective ODS table to a regular table. This is done by issuing ods output <ODS=table-name>= <table-to-save-it-into>; in front of your command. Assuming you want to save the ChiSq table the code looks like:
ods output ChiSq=work.my_chisq_table;
proc freq data=data;
tables var1*var2/chisq;
run;

The chi-square table will be saved as work.my_chisq_table and you can print it elsewhere.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM