<?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: How to generate the variable &amp;quot;frequency&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-the-variable-quot-frequency-quot/m-p/186345#M265697</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That works. Thank you, Keshan!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 19 Apr 2014 22:58:01 GMT</pubDate>
    <dc:creator>Jonate_H</dc:creator>
    <dc:date>2014-04-19T22:58:01Z</dc:date>
    <item>
      <title>How to generate the variable "frequency"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-the-variable-quot-frequency-quot/m-p/186341#M265693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For the attached sample data, I would like to generate the variable "frequency", its value is calculated by id and by year. what is the simply way to get that? I know that the simple way to get the variable "count" is something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sampledata;&lt;/P&gt;&lt;P&gt;&amp;nbsp; count + 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by id year;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.id or first.year then count = 1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Apr 2014 04:28:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-the-variable-quot-frequency-quot/m-p/186341#M265693</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2014-04-19T04:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate the variable "frequency"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-the-variable-quot-frequency-quot/m-p/186342#M265694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can do counts in SQL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc SQL ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; year&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count (id) as count&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; From have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Group by id, year &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;Quit ;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Or &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc Freq data = have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tables id * year&amp;nbsp; / out = want (drop = percent) ;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;You could also use Summary or Univariate if there is another numeric variable you can use for counting (use the N statistic).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Proc Report or Tabulate are also &lt;/SPAN&gt;options&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Richard&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Apr 2014 06:18:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-the-variable-quot-frequency-quot/m-p/186342#M265694</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2014-04-19T06:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate the variable "frequency"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-the-variable-quot-frequency-quot/m-p/186343#M265695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Richard!&lt;/P&gt;&lt;P&gt;In that way, I will have a summarized table as below first image shows.&lt;/P&gt;&lt;P&gt;so, in order to make the exact same data set as below second image shows, I will have to merge original data with the summarized table.&lt;/P&gt;&lt;P&gt;Is it possible that I can create the variable "frequency" without using merge?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the table I get by Richard's first code:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="6040" alt="frequency.png" class="jive-image" src="https://communities.sas.com/legacyfs/online/6040_frequency.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope to create the variable "frequency" directly in the original data set as below showed:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="6041" alt="results.png" class="jive-image" src="https://communities.sas.com/legacyfs/online/6041_results.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Apr 2014 13:47:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-the-variable-quot-frequency-quot/m-p/186343#M265695</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2014-04-19T13:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate the variable "frequency"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-the-variable-quot-frequency-quot/m-p/186344#M265696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Add some other variables other than group variable into sql.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Proc SQL ;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create table want as&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count (id) as count&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; From have&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Group by id, year&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Quit ;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Apr 2014 13:55:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-the-variable-quot-frequency-quot/m-p/186344#M265696</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-04-19T13:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate the variable "frequency"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-generate-the-variable-quot-frequency-quot/m-p/186345#M265697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That works. Thank you, Keshan!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Apr 2014 22:58:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-generate-the-variable-quot-frequency-quot/m-p/186345#M265697</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2014-04-19T22:58:01Z</dc:date>
    </item>
  </channel>
</rss>

