I created a dataset with all possible combinations of subgroup variables for a binary response. However, no subjects had a response value so PROC FREQ returns the following:
A row or column sum is zero for the table
I thought I could get around this by using PROC MEANS to fill all the zero response rows with zeros then use the WEIGHT count/zeros option in FREQ but it does not work. I'm trying to compute CIs for the binomial proportions. Any thoughts?
Example Data
Treat Var Count
Test Yes 0
Test No 100
Control Yes 0
Control No 100
Doesn't work is awful vague.
Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.
No output? Post any log in a code box.
Unexpected output? Provide input data in the form of data step code pasted into a code box, the code you used, the actual results and the expected results if possible. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
proc freq data = counts ;
where subgroupan = 1; <<<<-several subgroups does not matter which one
table trtpn*ev /out = x /*binomial riskdiff exact alpha = 0.1*/ outpct ;
weight count/zeros;
*ods output riskdiffcol2 = rd2;
run;
WARNING: Output 'riskdiffcol2' was not created. Make sure that the output object name, label, or path is spelled correctly. Also,
verify that the appropriate procedure options are used to produce the requested output object. For example, verify that
the NOPRINT option is not used.
@Doug____ wrote:
proc freq data = counts ;
where subgroupan = 1; <<<<-several subgroups does not matter which one
table trtpn*ev /out = x /*binomial riskdiff exact alpha = 0.1*/ outpct ;
weight count/zeros;
*ods output riskdiffcol2 = rd2;
run;
WARNING: Output 'riskdiffcol2' was not created. Make sure that the output object name, label, or path is spelled correctly. Also,
verify that the appropriate procedure options are used to produce the requested output object. For example, verify that
the NOPRINT option is not used.
Your "example data" in the first post does not include any variables name subgroupan trtpn or ev. So again, I request example data that causes the error.
It is very easy to make a small data set with data step code. From your "example data"
data have; input Treat $ Var $ Count; datalines; Test Yes 0 Test No 100 Control Yes 0 Control No 100 ; run;
The $ are used to read character values.
this is the example that causes the problem because there are no "yes" responses to FREQ does not calculate any CIs for the difference and returns a warning to the log.
@Doug____ wrote:
this is the example that causes the problem because there are no "yes" responses to FREQ does not calculate any CIs for the difference and returns a warning to the log.
From what you have shown so far we can't get to that stage. You have not shown values for any of the variables on the tables statement. So the only thing I can get is errors about missing variables.
Either provide data that matches the Proc Freq or provide proc freq that matches the data.
AGE1 | <55 | Control | No | 160 |
AGE1 | <55 | Control | Yes | 0 |
AGE1 | <55 | Test | No | 141 |
AGE1 | <55 | Test | Yes | 0 |
AGE1 | >=55 | Control | No | 98 |
AGE1 | >=55 | Control | Yes | 0 |
AGE1 | >=55 | Test | No | 113 |
AGE1 | >=55 | Test | Yes | 0 |
These are the summary count data being fed into proc freq
@Doug____ wrote:
AGE1
<55
Control
No
160
AGE1
<55
Control
Yes
0
AGE1
<55
Test
No
141
AGE1
<55
Test
Yes
0
AGE1
>=55
Control
No
98
AGE1
>=55
Control
Yes
0
AGE1
>=55
Test
No
113
AGE1
>=55
Test
Yes
0
These are the summary count data being fed into proc freq
And which variable is which in the Proc Freq code you showed? And that is not a data step and I am not going to clean up that format to make one.
Freq uses the count variable on the right with a weight statement. So the analysis is for each subgroup is the treatment (Control /Test) * the count variable. Then use the weight variable to get the percentages. Basically you can use the first two rows to run Freq since it is summary data. I was using Freq to get the CIs for the difference but it won't give those since there are no responses (everything is "No").
For 0 values try using the EXACT statement with PROC FREQ. You may also want to look into the ZEROS option.
https://communities.sas.com/t5/SAS-Procedures/Proc-Freq-All-inclusive-table/td-p/202542
Not sure if it’ll work for the CI but should appear in the table at least.
And another option that’s handy is the SPARSE option.
@Doug____ wrote:
Freq uses the count variable on the right with a weight statement. So the analysis is for each subgroup is the treatment (Control /Test) * the count variable. Then use the weight variable to get the percentages. Basically you can use the first two rows to run Freq since it is summary data. I was using Freq to get the CIs for the difference but it won't give those since there are no responses (everything is "No").
I am using weight/zeros already which from the documentation invokes the SPARSE option - the warning still appears.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.