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

Hi there, 

I was I am quite novice in  sas programming. I would really appreciate if someone can help me in solving my data analysis. I am doing a retrospective cohort study and trying to compare if operations done during the afterhours have more complications than daytime. I am doing a chisq test. I imported my data correctly in sas. As i can see that sas can read my data. However, when i am running chi sq test , it put in 1 in reach of the cells of the contingency table.

 

Please see my data steps below and the screenshot of the sas error result My dataMy dataSas error resultSas error resultand my dataset attached.

 filename refile '/home/u62871531/Audit.xlsx';


proc import datafile=refile
DBMS=XLSX
out=audit
replace;
run;
proc freq data=audit order=freq;
tables Group*Complications/chisq norow nopercent measures expected;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
antonbcristina
SAS Super FREQ

You'll want to add a WEIGHT statement in your call to PROC FREQ:

 

proc freq data=audit order=freq;
    tables Group*Complications/chisq norow nopercent measures expected;
    weight count;
run;

A weight statement will provide the counts required to perform a Chi-square test.

View solution in original post

3 REPLIES 3
antonbcristina
SAS Super FREQ

You'll want to add a WEIGHT statement in your call to PROC FREQ:

 

proc freq data=audit order=freq;
    tables Group*Complications/chisq norow nopercent measures expected;
    weight count;
run;

A weight statement will provide the counts required to perform a Chi-square test.

Bushra1
Calcite | Level 5
Thanks so much . It solved the problem. Really appreciate it.
WarrenKuhfeld
Ammonite | Level 13

If you are a novice at SAS, why would you assert that SAS, written by professional statisticians, is producing incorrect results? Where did you input your COUNT variable into the analysis? You did not. Look at the documentation and figure out how you add that variable. SAS is producing correct results. This is a user error.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 870 views
  • 0 likes
  • 3 in conversation