BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Merto
Calcite | Level 5

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_IDN_PCHI_P_PCHICATEGORY_1_PCT_ROWCATEGORY_2_PCT_ROWTOTAL _PCT_ROW
2750.6985780.40326191   
3162550.0206130.88583941   
424002.2890160.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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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.

View solution in original post

3 REPLIES 3
ballardw
Super User

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.

Merto
Calcite | Level 5

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?

 pic1.PNG

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_IDN_PCHI_P_PCHINON_WHITE_PCT_ROWWHITE_PCT_ROWTOTAL _PCT_ROW
2750.6985780.40326191   
Ksharp
Super User

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.

sas-innovate-2024.png

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.

 

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
  • 3 replies
  • 1461 views
  • 2 likes
  • 3 in conversation