<?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: Create a new variable based on the number of entries in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-the-number-of-entries/m-p/535943#M147222</link>
    <description>&lt;P&gt;If you want a new data set, then you'd just need to create an output data set from PROC FREQ. I used the LIST option, so if your variables were named STATE and COUNTY as shown in my example, then:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="output_data.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27179i6796AE8AC7455E41/image-size/large?v=v2&amp;amp;px=999" role="button" title="output_data.png" alt="output_data.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;and WORK.FRLIST would be the output data set.&lt;BR /&gt;Cynthia&lt;/P&gt;</description>
    <pubDate>Fri, 15 Feb 2019 17:59:54 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2019-02-15T17:59:54Z</dc:date>
    <item>
      <title>Create a new variable based on the number of entries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-the-number-of-entries/m-p/535920#M147211</link>
      <description>&lt;P&gt;I want to create a new variable based on the number of entries.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a sample of my dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HospitalName&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; City&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; State&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CountyName&lt;/P&gt;&lt;P&gt;Name 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Columbia&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Tx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Shelby&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would want a new variable to see how many hospitals are in each county specific to their state.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I be able to do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 17:23:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-the-number-of-entries/m-p/535920#M147211</guid>
      <dc:creator>jmariee</dc:creator>
      <dc:date>2019-02-15T17:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on the number of entries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-the-number-of-entries/m-p/535924#M147213</link>
      <description>&lt;P&gt;Proc freg data=have out=want;&lt;/P&gt;
&lt;P&gt;by state county;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#freq_toc.htm" target="_blank" rel="noopener"&gt;http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#freq_toc.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then you can merge the results from want back to have.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 17:36:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-the-number-of-entries/m-p/535924#M147213</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-02-15T17:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on the number of entries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-the-number-of-entries/m-p/535935#M147219</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt;This sounds like a simple PROC FREQ type of output. Do you need a data set or do you need a report?&lt;BR /&gt;I am guessing that your data set does not have just one row. So if you have a Texas County with 3 hospitals, would you expect to see a 3 in the new variable for each of the hospitals? &lt;BR /&gt;&lt;BR /&gt;It's not clear to me what you would want to see populated in your new variable. In the fake data, below, Shelby county has 3 hospitals, Anderson county has 4 hospitals, Bexar county has 2 and there there are different hospitals in Ohio -- it sounds to me like you want a new data set, with a count variable. Perhaps something like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="counties.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27178i52CDFA0C496513BD/image-size/large?v=v2&amp;amp;px=999" role="button" title="counties.png" alt="counties.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;The report on the right side shows output from PROC FREQ with the LIST option. Otherwise, I'm not sure how your original data would get the new variable populated on every row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 17:53:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-the-number-of-entries/m-p/535935#M147219</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-02-15T17:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on the number of entries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-the-number-of-entries/m-p/535938#M147220</link>
      <description>&lt;P&gt;Yes! I want a new data set with a count of how many hospitals there are in each county. Also for it to be categorized by state since some states have the same county names.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 17:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-the-number-of-entries/m-p/535938#M147220</guid>
      <dc:creator>jmariee</dc:creator>
      <dc:date>2019-02-15T17:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable based on the number of entries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-the-number-of-entries/m-p/535943#M147222</link>
      <description>&lt;P&gt;If you want a new data set, then you'd just need to create an output data set from PROC FREQ. I used the LIST option, so if your variables were named STATE and COUNTY as shown in my example, then:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="output_data.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27179i6796AE8AC7455E41/image-size/large?v=v2&amp;amp;px=999" role="button" title="output_data.png" alt="output_data.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;and WORK.FRLIST would be the output data set.&lt;BR /&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 17:59:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-variable-based-on-the-number-of-entries/m-p/535943#M147222</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-02-15T17:59:54Z</dc:date>
    </item>
  </channel>
</rss>

