<?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 do I count how many time a variable appears in a column in table in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392566#M25318</link>
    <description>Number of rows shouldn't be a problem.  Suggest you add data step code to make sample data with 10-20 example rows (using CARDS statement or whatever), and the PROC SQL code you ran.  That will make it easier for people to help you.  Many people won't open attachments (Excel etc), due to virus concerns etc.</description>
    <pubDate>Fri, 01 Sep 2017 14:55:00 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2017-09-01T14:55:00Z</dc:date>
    <item>
      <title>How do I count how many time a variable appears in a column in table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392538#M25311</link>
      <description>&lt;P&gt;I am trying to create a column that will show a count of how many times a variable (deal_id) appears in a column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the below example I would want deal_id's &amp;nbsp;100477 and 101797 to have a 2 and 102913 to have a one. &amp;nbsp;The 2 items that broken out need to be that way due to LGD diving factors downstream.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using PROC sql to create my tables and have tried using count(deal_id) and count(distinct deal_id) but they both returned a 1 value for all rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is just a portion of what the entire table consists of&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;reporting_date&lt;/TD&gt;&lt;TD&gt;source_system_code&lt;/TD&gt;&lt;TD&gt;deal_id&lt;/TD&gt;&lt;TD&gt;Notional_USD&lt;/TD&gt;&lt;TD&gt;LGD&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;04/30/2017&lt;/TD&gt;&lt;TD&gt;ACBS&lt;/TD&gt;&lt;TD&gt;100477&lt;/TD&gt;&lt;TD&gt;251019.46&lt;/TD&gt;&lt;TD&gt;0.31684&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;04/30/2017&lt;/TD&gt;&lt;TD&gt;ACBS&lt;/TD&gt;&lt;TD&gt;100477&lt;/TD&gt;&lt;TD&gt;10000&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;04/30/2017&lt;/TD&gt;&lt;TD&gt;ACBS&lt;/TD&gt;&lt;TD&gt;101797&lt;/TD&gt;&lt;TD&gt;5506337.48&lt;/TD&gt;&lt;TD&gt;0.31684&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;04/30/2017&lt;/TD&gt;&lt;TD&gt;ACBS&lt;/TD&gt;&lt;TD&gt;101797&lt;/TD&gt;&lt;TD&gt;50000&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;04/30/2017&lt;/TD&gt;&lt;TD&gt;ACBS&lt;/TD&gt;&lt;TD&gt;102913&lt;/TD&gt;&lt;TD&gt;6142612.78&lt;/TD&gt;&lt;TD&gt;0.17466&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;04/30/2017&lt;/TD&gt;&lt;TD&gt;ACBS&lt;/TD&gt;&lt;TD&gt;103074&lt;/TD&gt;&lt;TD&gt;11416126.66&lt;/TD&gt;&lt;TD&gt;0.31684&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 01 Sep 2017 14:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392538#M25311</guid>
      <dc:creator>jtennyson</dc:creator>
      <dc:date>2017-09-01T14:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count how many time a variable appears in a column in table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392546#M25312</link>
      <description>&lt;P&gt;Is the desired output a data set or a report? If a data set are you merging the results back onto the original data so the same value appears on each record?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It really helps to show exactly what the actual output should be.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 14:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392546#M25312</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-01T14:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count how many time a variable appears in a column in table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392549#M25313</link>
      <description>&lt;P&gt;I am creating a data set to be used for reporting&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am combining a few tables to be used for reporting ( source data is very large.) &amp;nbsp;My problem arose when I tried&amp;nbsp;to combine another table to pull in an interest column (which has deal_id and interest no duplicates) and saw that values were being duplicated due to the deal_id being on multiple rows. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been spinning my wheels on how to get this dat to pull once and my thought is to generate a count of deal_id and divide by that to remedy this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&l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;&lt;TD&gt;4/30/2017&lt;/TD&gt;&lt;TD&gt;ACBS&lt;/TD&gt;&lt;TD&gt;103074&lt;/TD&gt;&lt;TD&gt;11416126.7&lt;/TD&gt;&lt;TD&gt;0.3168&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 01 Sep 2017 14:23:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392549#M25313</guid>
      <dc:creator>jtennyson</dc:creator>
      <dc:date>2017-09-01T14:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count how many time a variable appears in a column in table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392550#M25314</link>
      <description>&lt;PRE&gt;proc sql noprint;
  create table want as
    select *,count(deal_id) as count
      from have
        group by deal_id
  ;
quit;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 14:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392550#M25314</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-09-01T14:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count how many time a variable appears in a column in table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392551#M25315</link>
      <description>&lt;P&gt;What SQL code did you try?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would try something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input deal_id Notional_USD;
cards;
100477 251019.46
100477 10000
101797 5506337.48
101797 50000
102913 6142612.78
103074 11416126.66
;

proc sql;
  select * , count(*) as DealCount
    from have 
    group by deal_id
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Returns:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; deal_id  Notional_USD  DealCount
  100477         10000          2
  100477      251019.5          2
  101797       5506337          2
  101797         50000          2
  102913       6142613          1
  103074      11416127          1
&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Sep 2017 14:30:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392551#M25315</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-09-01T14:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count how many time a variable appears in a column in table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392557#M25316</link>
      <description>&lt;P&gt;I think my issue arises from my data being much larger than my example. I have attached an example (actual details have over 20k rows) of what I am trying to accomplish along with the SQL I wrote.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I either would like to count the times a variable appears in my table and do some simple math, or pull data from the AIR table only once.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try adding Count(Deal_id) or Count (distinct deal_id) I get a value of 1 in return.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 14:51:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392557#M25316</guid>
      <dc:creator>jtennyson</dc:creator>
      <dc:date>2017-09-01T14:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count how many time a variable appears in a column in table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392566#M25318</link>
      <description>Number of rows shouldn't be a problem.  Suggest you add data step code to make sample data with 10-20 example rows (using CARDS statement or whatever), and the PROC SQL code you ran.  That will make it easier for people to help you.  Many people won't open attachments (Excel etc), due to virus concerns etc.</description>
      <pubDate>Fri, 01 Sep 2017 14:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392566#M25318</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-09-01T14:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count how many time a variable appears in a column in table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392567#M25319</link>
      <description>&lt;P&gt;You're grouping by a large collection of variables rather than just the one(s) you're interested in. Also, I didn't find a file in your attachments that showed the raw data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 14:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392567#M25319</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-09-01T14:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count how many time a variable appears in a column in table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392569#M25320</link>
      <description>&lt;P&gt;Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Better would be to provide some example data and what the final report should look like. If you haven't explored Procs Report and Tabulate you might be surprised what is possible though all of the variables of interest do need to be&amp;nbsp;in one data set for those.&lt;/P&gt;
&lt;P&gt;Paste code into a code box using the forum {i} menu icon.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 14:58:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392569#M25320</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-01T14:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count how many time a variable appears in a column in table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392585#M25321</link>
      <description>&lt;P&gt;That was it! I limited the grouping and now I'm getting the result I was looking for!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you everyone!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 15:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-count-how-many-time-a-variable-appears-in-a-column-in/m-p/392585#M25321</guid>
      <dc:creator>jtennyson</dc:creator>
      <dc:date>2017-09-01T15:48:40Z</dc:date>
    </item>
  </channel>
</rss>

