title: SAS: PROC FREQ with multiple ID variables
body: <p>I have data that's tracking a certain eye phenomena. Some patients have it in both eyes, and some patients have it in a single eye. This is what some of the data looks like:</p>
  
  <pre><code>EyeID   PatientID   STATUS  Gender
  1   1   1   M
  2   1   0   M
  3   2   1   M
  4   3   0   M
  5   3   1   M
  6   4   1   M
  7   4   0   M
  8   5   1   F
  9   6   1   F
  10  6   0   F
  11  7   1   F
  12  8   1   F
  13  8   0   F
  14  9   1   F
  </code></pre>
  
  <p>As you can see from the data above, there are 9 patients total and all of them have the particular phenomena in one eye. </p>
  
  <p>I need the count the number of patients with this eye phenomena. 
  To get the number of total patients in the dataset, I used:</p>
  
  <pre><code>PROC FREQ data=new nlevels;
  tables PatientID;
  run;
  </code></pre>
  
  <p>To count the number of patients with this eye phenomena, I used: </p>
  
  <pre><code>PROC SORT data=new out=new1 nodupkey;
  by Patientid Status;
  run;
  
  proc freq data=new1 nlevels;
  tables Status;
  run;
  </code></pre>
  
  <p>However, it gave the correct number of patients with the phenomena (9), but not the correct number without (0).</p>
  
  <p><a href="https://i.stack.imgur.com/9P0wI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9P0wI.png" alt="enter image description here"></a></p>
  
  <p>I now need to calculate the gender distribution of this phenomena. I used: </p>
  
  <pre><code>proc freq data=new1;
  tables gender*Status/chisq;
  run;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/0FtBS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0FtBS.png" alt="enter image description here"></a></p>
  
  <p>However, in the cross table, it has the correct number of patients who have the phenomena (9), but not the correct number without (0). Does anyone have any thoughts on how to do this chi-square, where if the has this phenomena in at least 1 eye, then they are positive for this phenomena?</p>
  
  <p>Thanks!</p>