I have ran FREQ Procedure to get a 2 by 2 frequency table and Chi Square Statistics for 20 measures. I'd like to create an output to include only row percentages for each category and total percentages from the frequency table, and Pearson chi-square statistics together. Now I only generated an output for Chi Square Stats. Is there any functions I can use to get the final result like the table below? Thanks a lot in advance.
MEASURE_ID | N | _PCHI_ | P_PCHI | CATEGORY_1_PCT_ROW | CATEGORY_2_PCT_ROW | TOTAL _PCT_ROW |
2 | 75 | 0.698578 | 0.40326191 | |||
3 | 16255 | 0.020613 | 0.88583941 | |||
4 | 2400 | 2.289016 | 0.13029252 |
PROC FREQ DATA = DATASET;
BY MEASURE_ID;
TABLE ETHNICITY * COMP_IND/CHISQ ;
OUTPUT OUT=ChiSqData_V1 N PCHI;
WEIGHT COUNT;
RUN;
PROC PRINT DATA=ChiSqData_V1 noobs ;
RUN;
Can you post your data and the output.
I think you can use SQL to get that row_pct , after using proc freq to get that Chisquare,
you can combine them together into one table.
You may need to provide some example data with calculated percentages as you need them. I am not sure at the moment what CATEGORY_1_PCT_ROW is actually. OR as a very bare minimum provide what is included in the numerator and denominator for the percentages. You may well have to have more than one data set and combine them.
You can get the row and column percentages by using the OUT= option on the TABLES statement with OUTPCT. Depending on what you are doing OUTEXPECT to get the expected frequency used in chi-square calculations may be helpful.
Thank you ballardw. I tried the OUT= option on the TABLES statement with OUTPCT, but it only gives me the row and column percentages, but not the total percentages. For example, I would like to have the compliance rates (row percentages) of non_white (90.24%) and white (76.47%), and the total compliance rate (84%) according to the table below.
My question number 1 will be: how can I get the total percent (84%) as well?
Question number 2 is: in order to put values in the format below, is there a pivot function in proc sql that allows me to transpose data?
MEASURE_ID | N | _PCHI_ | P_PCHI | NON_WHITE_PCT_ROW | WHITE_PCT_ROW | TOTAL _PCT_ROW |
2 | 75 | 0.698578 | 0.40326191 |
Can you post your data and the output.
I think you can use SQL to get that row_pct , after using proc freq to get that Chisquare,
you can combine them together into one table.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.