<?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: trying to figure out is how many instances of each postal code is affiliated with a hospital in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/trying-to-figure-out-is-how-many-instances-of-each-postal-code/m-p/453940#M284113</link>
    <description>&lt;P&gt;Another way if you want a human to read it and not use a resulting data set as input to something else would be one of the report or summarization procedures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data work.hospital_by_pc;
   input ID Hospital  Postcode $;
   datalines;
1 11 M4T
2 11 M4T
3 11 M4R
3 11 M4N
4 12 D2F
5 12 D1J
6 12 D1J
7 14 M4T
8 14 D2F
;

proc tabulate data=work.hospital_by_pc;
   class hospital postcode;
   table hospital*postcode,
         n;
run;

proc freq data=work.hospital_by_pc;
   tables hospital*postcode/list nocum nopercent;
run;&lt;/PRE&gt;
&lt;P&gt;Note changes to your data step so that postcode is actually read (your code had it numeric with character values) and the ; to end datalines has to be on a separate line from the end of the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that both of these approaches lend them selves to also generate a "which hospitals go&amp;nbsp;with which code". Such as&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=work.hospital_by_pc;
   class hospital postcode;
   table hospital*postcode,
         n ;
   table postcode*hospital ,
         n ;
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Apr 2018 14:56:21 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-04-13T14:56:21Z</dc:date>
    <item>
      <title>trying to figure out is how many instances of each postal code is affiliated with a hospital</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trying-to-figure-out-is-how-many-instances-of-each-postal-code/m-p/453917#M284111</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set that looks roughly like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data hospital_by_pc;
   input ID Hospital Postcode;
   datalines;
1 11 M4T
2 11 M4T
3 11 M4R
3 11 M4N
4 12 D2F
5 12 D1J
6 12 D1J
7 14 M4T
8 14 D2F;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What I need to figure out is how many instances of each postal code is affiliated with each hospital. So the output would look roughly like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For hospital #11&lt;/P&gt;&lt;P&gt;2 from M4T&lt;/P&gt;&lt;P&gt;1 from M4R&lt;/P&gt;&lt;P&gt;1 from M4N&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For Hospital #12&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 from D2F&lt;/P&gt;&lt;P&gt;2 from D1J&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From Hospital #14&lt;/P&gt;&lt;P&gt;1 from M4T&lt;/P&gt;&lt;P&gt;1 from D2F&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In essence I'm trying to figure out how many people from each postal code are going to each hospital.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts would be much appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mike&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 14:11:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trying-to-figure-out-is-how-many-instances-of-each-postal-code/m-p/453917#M284111</guid>
      <dc:creator>righcoastmike</dc:creator>
      <dc:date>2018-04-13T14:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: trying to figure out is how many instances of each postal code is affiliated with a hospital</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trying-to-figure-out-is-how-many-instances-of-each-postal-code/m-p/453920#M284112</link>
      <description>&lt;P&gt;There are numerous methods - means, summary, - but I tend to jump right at SQL for simple summary stats:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table want as
  select hospital,
         postcode,
         count(*) as want
  from   hospital_by_pc
  group by hospital,
           postcode;
quit;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Apr 2018 14:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trying-to-figure-out-is-how-many-instances-of-each-postal-code/m-p/453920#M284112</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-13T14:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: trying to figure out is how many instances of each postal code is affiliated with a hospital</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trying-to-figure-out-is-how-many-instances-of-each-postal-code/m-p/453940#M284113</link>
      <description>&lt;P&gt;Another way if you want a human to read it and not use a resulting data set as input to something else would be one of the report or summarization procedures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data work.hospital_by_pc;
   input ID Hospital  Postcode $;
   datalines;
1 11 M4T
2 11 M4T
3 11 M4R
3 11 M4N
4 12 D2F
5 12 D1J
6 12 D1J
7 14 M4T
8 14 D2F
;

proc tabulate data=work.hospital_by_pc;
   class hospital postcode;
   table hospital*postcode,
         n;
run;

proc freq data=work.hospital_by_pc;
   tables hospital*postcode/list nocum nopercent;
run;&lt;/PRE&gt;
&lt;P&gt;Note changes to your data step so that postcode is actually read (your code had it numeric with character values) and the ; to end datalines has to be on a separate line from the end of the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that both of these approaches lend them selves to also generate a "which hospitals go&amp;nbsp;with which code". Such as&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=work.hospital_by_pc;
   class hospital postcode;
   table hospital*postcode,
         n ;
   table postcode*hospital ,
         n ;
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 14:56:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trying-to-figure-out-is-how-many-instances-of-each-postal-code/m-p/453940#M284113</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-13T14:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: trying to figure out is how many instances of each postal code is affiliated with a hospital</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trying-to-figure-out-is-how-many-instances-of-each-postal-code/m-p/453965#M284114</link>
      <description>&lt;P&gt;This is exactly what I was looking for. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, lesson learned on the input code, thanks for pointing out the syntax problems. It really is like learning a new language. I'll get there eventually.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mike&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 15:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trying-to-figure-out-is-how-many-instances-of-each-postal-code/m-p/453965#M284114</guid>
      <dc:creator>righcoastmike</dc:creator>
      <dc:date>2018-04-13T15:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: trying to figure out is how many instances of each postal code is affiliated with a hospital</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trying-to-figure-out-is-how-many-instances-of-each-postal-code/m-p/453967#M284115</link>
      <description>&lt;P&gt;This also worked really well, thanks so much.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;your help is much appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mike&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 15:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trying-to-figure-out-is-how-many-instances-of-each-postal-code/m-p/453967#M284115</guid>
      <dc:creator>righcoastmike</dc:creator>
      <dc:date>2018-04-13T15:59:08Z</dc:date>
    </item>
  </channel>
</rss>

