<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Freq table help? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Freq-table-help/m-p/9948#M114</link>
    <description>Data step code could certainly construct the frequencies which you need.&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=mydata;&lt;BR /&gt;
 &amp;nbsp; by facilityID SSN;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data freqs;&lt;BR /&gt;
 &amp;nbsp; set mydata;&lt;BR /&gt;
 &amp;nbsp; by facilityID ssn;&lt;BR /&gt;
 &amp;nbsp; if first.facilityID then do;&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; NRestr1=0; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* Number of times restraint 1 used */&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; NPatRestr1=0; &amp;nbsp; /*Number of patients for whom restraint 1 was used */&lt;BR /&gt;
&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; NRestr2=0; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* Number of times restraint 2 used */&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; NPatRestr2=0; &amp;nbsp; /*Number of patients for whom restraint 2 was used */&lt;BR /&gt;
&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; ...&lt;BR /&gt;
 &amp;nbsp; end;&lt;BR /&gt;
&lt;BR /&gt;
 &amp;nbsp; if first.SSN then do;&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; PatRestr1=0; &amp;nbsp; /* Restraint 1 ever used on patient */&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; PatRestr2=0; &amp;nbsp; /* Restraint 2 ever used on patient */&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; ...&lt;BR /&gt;
 &amp;nbsp; end;&lt;BR /&gt;
&lt;BR /&gt;
 &amp;nbsp; NRestr1 + Restr1; &amp;nbsp; /* Increment total use of restraint 1 */&lt;BR /&gt;
 &amp;nbsp; NRestr2 + Restr2; &amp;nbsp; /* Increment total use of restraint 2 */&lt;BR /&gt;
 &amp;nbsp; ...&lt;BR /&gt;
&lt;BR /&gt;
 &amp;nbsp; PatRestr1 = max(PatRestr1, Restr1); &amp;nbsp; /* Update indicator of patient ever using restraint 1 */&lt;BR /&gt;
 &amp;nbsp; PatRestr2 = max(PatRestr2, Restr2); &amp;nbsp; /* Update indicator of patient ever using restraint 2 */&lt;BR /&gt;
 &amp;nbsp; ...&lt;BR /&gt;
&lt;BR /&gt;
 &amp;nbsp; if last.SSN then do;&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; NPatRestr1 + PatRestr1; &amp;nbsp; /* Increment count of patients using restraint 1 */&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; NPatRestr2 + PatRestr2; &amp;nbsp; /* Increment count of patients using restraint 2 */&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; ...&lt;BR /&gt;
 &amp;nbsp; end;&lt;BR /&gt;
&lt;BR /&gt;
 &amp;nbsp; if last.FacilityID then output;&lt;BR /&gt;
 &amp;nbsp; keep facilityID NRestr1 NpatRestr1 NRestr2 NpatRestr2;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=freqs;&lt;BR /&gt;
run;</description>
    <pubDate>Tue, 05 Oct 2010 20:33:23 GMT</pubDate>
    <dc:creator>Dale</dc:creator>
    <dc:date>2010-10-05T20:33:23Z</dc:date>
    <item>
      <title>Freq table help?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Freq-table-help/m-p/9947#M113</link>
      <description>Good morning, &lt;BR /&gt;
&lt;BR /&gt;
I am trying to code for a situation I have never seen before. &lt;BR /&gt;
I am trying to display a frequency table of different facilities and the amount of physical restraints used divided by types. IE&amp;gt;&lt;BR /&gt;
&lt;BR /&gt;
(Facility ID)         (Restr 1)   	(Restr 2)&lt;BR /&gt;
1	                     42	           35&lt;BR /&gt;
2	                     342	           32&lt;BR /&gt;
3	                     23423	           343&lt;BR /&gt;
&lt;BR /&gt;
Each row is considered an admission to the facility, having a patient SSN attached to it. I also need to determine how many patients per restraint per facility. This would be determined by how many different social security numbers per restraint per facility ID , and somehow doing a count function. &lt;BR /&gt;
The data is similar to this….&lt;BR /&gt;
&lt;BR /&gt;
(Facility ID)	   ( SSN)	   ( Restr 1)	  (Restr 2)&lt;BR /&gt;
1	                    1233	        1	            0&lt;BR /&gt;
1	                    1233	        1	            0&lt;BR /&gt;
1	                    1554	        0	            1 &lt;BR /&gt;
2	                    1111	        1	            0&lt;BR /&gt;
2	                    1224	        0	            1&lt;BR /&gt;
2	                    1224	        0	            1&lt;BR /&gt;
Legend: restraint1=0, no restraint used, restraint 1=1, restraint used&lt;BR /&gt;
&lt;BR /&gt;
I want a table to be generated from the above sample data to look like this…&lt;BR /&gt;
&lt;BR /&gt;
(Facility ID)   (Restr1)	(# of Patients used restr1) (Restr 2)  (# of Patients used restr2)&lt;BR /&gt;
       1	         2	                 1	                    1                    	1&lt;BR /&gt;
       2	         1	                 1	                    2	                        1&lt;BR /&gt;
&lt;BR /&gt;
I am using enterprise as well. I suppose it has something to do with DupOUT but I am not as familiar with that function.  Any help would be greatly appreciated!</description>
      <pubDate>Thu, 30 Sep 2010 15:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Freq-table-help/m-p/9947#M113</guid>
      <dc:creator>slivingston1</dc:creator>
      <dc:date>2010-09-30T15:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Freq table help?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Freq-table-help/m-p/9948#M114</link>
      <description>Data step code could certainly construct the frequencies which you need.&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=mydata;&lt;BR /&gt;
 &amp;nbsp; by facilityID SSN;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data freqs;&lt;BR /&gt;
 &amp;nbsp; set mydata;&lt;BR /&gt;
 &amp;nbsp; by facilityID ssn;&lt;BR /&gt;
 &amp;nbsp; if first.facilityID then do;&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; NRestr1=0; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* Number of times restraint 1 used */&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; NPatRestr1=0; &amp;nbsp; /*Number of patients for whom restraint 1 was used */&lt;BR /&gt;
&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; NRestr2=0; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* Number of times restraint 2 used */&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; NPatRestr2=0; &amp;nbsp; /*Number of patients for whom restraint 2 was used */&lt;BR /&gt;
&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; ...&lt;BR /&gt;
 &amp;nbsp; end;&lt;BR /&gt;
&lt;BR /&gt;
 &amp;nbsp; if first.SSN then do;&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; PatRestr1=0; &amp;nbsp; /* Restraint 1 ever used on patient */&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; PatRestr2=0; &amp;nbsp; /* Restraint 2 ever used on patient */&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; ...&lt;BR /&gt;
 &amp;nbsp; end;&lt;BR /&gt;
&lt;BR /&gt;
 &amp;nbsp; NRestr1 + Restr1; &amp;nbsp; /* Increment total use of restraint 1 */&lt;BR /&gt;
 &amp;nbsp; NRestr2 + Restr2; &amp;nbsp; /* Increment total use of restraint 2 */&lt;BR /&gt;
 &amp;nbsp; ...&lt;BR /&gt;
&lt;BR /&gt;
 &amp;nbsp; PatRestr1 = max(PatRestr1, Restr1); &amp;nbsp; /* Update indicator of patient ever using restraint 1 */&lt;BR /&gt;
 &amp;nbsp; PatRestr2 = max(PatRestr2, Restr2); &amp;nbsp; /* Update indicator of patient ever using restraint 2 */&lt;BR /&gt;
 &amp;nbsp; ...&lt;BR /&gt;
&lt;BR /&gt;
 &amp;nbsp; if last.SSN then do;&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; NPatRestr1 + PatRestr1; &amp;nbsp; /* Increment count of patients using restraint 1 */&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; NPatRestr2 + PatRestr2; &amp;nbsp; /* Increment count of patients using restraint 2 */&lt;BR /&gt;
 &amp;nbsp; &amp;nbsp; ...&lt;BR /&gt;
 &amp;nbsp; end;&lt;BR /&gt;
&lt;BR /&gt;
 &amp;nbsp; if last.FacilityID then output;&lt;BR /&gt;
 &amp;nbsp; keep facilityID NRestr1 NpatRestr1 NRestr2 NpatRestr2;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=freqs;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 05 Oct 2010 20:33:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Freq-table-help/m-p/9948#M114</guid>
      <dc:creator>Dale</dc:creator>
      <dc:date>2010-10-05T20:33:23Z</dc:date>
    </item>
  </channel>
</rss>

