turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- How to create an output including row & total perc...

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-07-2016 02:58 PM

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**;

Accepted Solutions

Solution

10-13-2016
11:30 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Merto

10-07-2016 11:49 PM

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.

All Replies

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Merto

10-07-2016 03:29 PM

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ballardw

10-07-2016 05:08 PM

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 |

Solution

10-13-2016
11:30 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Merto

10-07-2016 11:49 PM

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.