<?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 use a COUNTIF function within computed column of query builder? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412339#M26511</link>
    <description>&lt;P&gt;This is why we always ask for test data, its impossible to guess what you are working with.&amp;nbsp; You can concatenate the wanted variables together then count across that:&lt;/P&gt;
&lt;PRE&gt;count(catx(',',of decisiononothercode:),'myword') as want&lt;/PRE&gt;
&lt;P&gt;So the catx() takes all variables with prefix decisiononothercode, puts all the strings together with commas separating.&amp;nbsp; Then the count function scans that string for occurences of myword and returns the number found.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Nov 2017 14:16:03 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-11-10T14:16:03Z</dc:date>
    <item>
      <title>How do I use a COUNTIF function within computed column of query builder?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412317#M26506</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've got a table of data where a certain string of text can appear in a variety of variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use one computed column (in query builder) that counts how many times the string appears in a range of variables, rather than using multiple computed columns to count the occurrence of the string in each variable separately, as you would with the COUNTIF function over a range of cells in Excel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If it helps, I'm using SAS EG 7.1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 13:24:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412317#M26506</guid>
      <dc:creator>CWilson4815</dc:creator>
      <dc:date>2017-11-10T13:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use a COUNTIF function within computed column of query builder?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412322#M26507</link>
      <description>&lt;P&gt;Use the count() function:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002260230.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002260230.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 13:41:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412322#M26507</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-10T13:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use a COUNTIF function within computed column of query builder?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412326#M26508</link>
      <description>Thanks for the reply RW9 but how can I use this function with multiple variables being fed into the formula?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For example, if I separate them by commas, then the function doesn't work.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;To put it into context, I have 10 columns I would like to reference (DECISIONOTHERCODE1,...,DECISIONOTHERCODE10) and my table name is t1.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Nov 2017 13:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412326#M26508</guid>
      <dc:creator>CWilson4815</dc:creator>
      <dc:date>2017-11-10T13:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use a COUNTIF function within computed column of query builder?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412339#M26511</link>
      <description>&lt;P&gt;This is why we always ask for test data, its impossible to guess what you are working with.&amp;nbsp; You can concatenate the wanted variables together then count across that:&lt;/P&gt;
&lt;PRE&gt;count(catx(',',of decisiononothercode:),'myword') as want&lt;/PRE&gt;
&lt;P&gt;So the catx() takes all variables with prefix decisiononothercode, puts all the strings together with commas separating.&amp;nbsp; Then the count function scans that string for occurences of myword and returns the number found.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 14:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412339#M26511</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-10T14:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use a COUNTIF function within computed column of query builder?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412371#M26515</link>
      <description>&lt;P&gt;I understand the logic behind these functions&amp;nbsp;but I am receiving a syntax error when trying to run this in my query builder as below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(COUNT(CATX(',',of DECISIONOTHERCODE:),'RS006 - CONSUMER.PRIMARY')) AS RS006&lt;BR /&gt;_________________&lt;BR /&gt;22&lt;BR /&gt;202&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, (, ), *, **, +, ',', -, '.', /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND,&lt;BR /&gt;BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||,&lt;BR /&gt;~, ~=.&lt;/P&gt;&lt;P&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What exactly does the of and colon do in your code?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 15:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412371#M26515</guid>
      <dc:creator>CWilson4815</dc:creator>
      <dc:date>2017-11-10T15:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use a COUNTIF function within computed column of query builder?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412381#M26517</link>
      <description>&lt;P&gt;Use the {i} above post for the code window to preserve formatting.&amp;nbsp; The colon indicates all variables with the prefix of the text before it, so you can read as "of all variables with decisiononothercoe prefix":&lt;/P&gt;
&lt;PRE&gt;count(catx(',',of DECISIONOTHERCODES:),'RS006 - CONSUMER.PRIMARY')) AS RS006&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; That syntax should work - I have none of your data to work with of course, but a similar code does:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  select count(catx(',',make,model,type),"Acura") as tmp
  from sashelp.cars;
quit;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Nov 2017 15:24:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412381#M26517</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-10T15:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use a COUNTIF function within computed column of query builder?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412390#M26519</link>
      <description>&lt;P&gt;I followed your code from the cars example to help as the of and : function still wasn't working for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I ended up having to write it as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;COUNT(CATX(',',DECISIONOTHERCODE1,DECISIONOTHERCODE2,DECISIONOTHERCODE3,DECISIONOTHERCODE4,DECISIONOTHERCODE5,DECISIONOTHERCODE6,DECISIONOTHERCODE7,DECISIONOTHERCODE8,DECISIONOTHERCODE9,DECISIONOTHERCODE10),'RS006 - CONSUMER.PRIMARY')&lt;/PRE&gt;&lt;P&gt;Thanks a lot for your help.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 15:44:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-use-a-COUNTIF-function-within-computed-column-of-query/m-p/412390#M26519</guid>
      <dc:creator>CWilson4815</dc:creator>
      <dc:date>2017-11-10T15:44:25Z</dc:date>
    </item>
  </channel>
</rss>

