<?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: Count of variable in table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-of-variable-in-table/m-p/346247#M79813</link>
    <description>&lt;P&gt;Easiest is likely proc freq:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; tables item;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to generate a data set add an output data set instruction&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; tables item/ out=item_count;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the data set Item_count will also have a percent you could remove by adding (drop=percent) after the dataset name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 31 Mar 2017 17:29:20 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-03-31T17:29:20Z</dc:date>
    <item>
      <title>Count of variable in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-of-variable-in-table/m-p/346243#M79811</link>
      <description>&lt;P&gt;First post and I'm a beginner in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking to count the variables in a table. I have them grouped or sorted. Below is my example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table_1&lt;/P&gt;&lt;P&gt;ITEM&lt;/P&gt;&lt;P&gt;red&lt;BR /&gt;blue&lt;BR /&gt;blue&lt;BR /&gt;yellow&lt;BR /&gt;yellow&lt;BR /&gt;yellow&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected outcome in new table (Table_2) or appended to Table_1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ITEM&amp;nbsp;&amp;nbsp;&amp;nbsp; COUNT&lt;/P&gt;&lt;P&gt;red&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;BR /&gt;blue&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 2&lt;BR /&gt;yellow&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get Table_1 as above or&amp;nbsp;a new Table_2 with the outcome?&lt;/P&gt;&lt;P&gt;Thanks - Adam&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 17:24:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-of-variable-in-table/m-p/346243#M79811</guid>
      <dc:creator>AdamR</dc:creator>
      <dc:date>2017-03-31T17:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: Count of variable in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-of-variable-in-table/m-p/346247#M79813</link>
      <description>&lt;P&gt;Easiest is likely proc freq:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; tables item;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to generate a data set add an output data set instruction&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; tables item/ out=item_count;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the data set Item_count will also have a percent you could remove by adding (drop=percent) after the dataset name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 17:29:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-of-variable-in-table/m-p/346247#M79813</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-31T17:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: Count of variable in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-of-variable-in-table/m-p/346257#M79815</link>
      <description>&lt;P&gt;I'm sorry, I'm really new to this. How would the suggested code&amp;nbsp;be exactly with Table_1 and Item (my table name and the variable)?&lt;/P&gt;&lt;P&gt;Thanks - Adam&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 17:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-of-variable-in-table/m-p/346257#M79815</guid>
      <dc:creator>AdamR</dc:creator>
      <dc:date>2017-03-31T17:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Count of variable in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-of-variable-in-table/m-p/346275#M79824</link>
      <description>&lt;P&gt;Figured it out:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data = Table_1 order = freq NOPRINT;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tables Item / nocum nopercent out = Table_2 (drop=percent);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help ballardw!&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 18:32:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-of-variable-in-table/m-p/346275#M79824</guid>
      <dc:creator>AdamR</dc:creator>
      <dc:date>2017-03-31T18:32:53Z</dc:date>
    </item>
  </channel>
</rss>

