<?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: Condition based counting in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Condition-based-counting/m-p/348463#M80693</link>
    <description>&lt;P&gt;proc sql doesn't support if then statements. I think you are looking for something like (untested):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table gender_dispurtion as
    select  country, count(*) as females
      from customer_1 (where=(gender eq 'F'))
        group by country
          order by country
  ;
quit;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
    <pubDate>Sat, 08 Apr 2017 22:38:36 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-04-08T22:38:36Z</dc:date>
    <item>
      <title>Condition based counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-based-counting/m-p/348462#M80692</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to count the number of females in each country and group it by country in my data set. I've posted my code thus far but am not getting far.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table gender_dispurtion as
select gender, country,
	if gender = 'F' then
		count(*) label = '#_females'
	end
from customer_1
group by country
order by country;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;38 if gender = 'F' then&lt;BR /&gt;------ -&lt;BR /&gt;1 22&lt;BR /&gt;200&lt;BR /&gt;WARNING 1-322: Assuming the symbol GE was misspelled as gender.&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,&lt;BR /&gt;a numeric constant, a datetime constant, a missing value, (, +, -, ALL, ANY, BTRIM,&lt;BR /&gt;CALCULATED, CASE, INPUT, PUT, SELECT, SOME, SUBSTRING, TRANSLATE, USER.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;39 count(*) label = '#_females'&lt;BR /&gt;40 end&lt;BR /&gt;---&lt;BR /&gt;22&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: ',', AS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've attached my data set in excel because it does not allow me to attach SAS data tables for some reason.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 08 Apr 2017 22:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-based-counting/m-p/348462#M80692</guid>
      <dc:creator>Scott86</dc:creator>
      <dc:date>2017-04-08T22:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: Condition based counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-based-counting/m-p/348463#M80693</link>
      <description>&lt;P&gt;proc sql doesn't support if then statements. I think you are looking for something like (untested):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table gender_dispurtion as
    select  country, count(*) as females
      from customer_1 (where=(gender eq 'F'))
        group by country
          order by country
  ;
quit;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Sat, 08 Apr 2017 22:38:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-based-counting/m-p/348463#M80693</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-08T22:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: Condition based counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-based-counting/m-p/348464#M80694</link>
      <description>proc sql;&lt;BR /&gt;create table gender_dispurtion as&lt;BR /&gt;Select count(gender),country from customer_1 where upcase(gender) eq 'F'&lt;BR /&gt;group by country;&lt;BR /&gt;quit;</description>
      <pubDate>Sun, 09 Apr 2017 00:05:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-based-counting/m-p/348464#M80694</guid>
      <dc:creator>lakshmi_74</dc:creator>
      <dc:date>2017-04-09T00:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Condition based counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-based-counting/m-p/348465#M80695</link>
      <description>&lt;P&gt;I would suggest PROC FREQ&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FREQ data = customer_1;

table country*gender  / out= summary_by_gender;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Apr 2017 00:07:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-based-counting/m-p/348465#M80695</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-09T00:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: Condition based counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-based-counting/m-p/348475#M80701</link>
      <description>&lt;P&gt;Thanks everyone &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2017 03:29:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-based-counting/m-p/348475#M80701</guid>
      <dc:creator>Scott86</dc:creator>
      <dc:date>2017-04-09T03:29:52Z</dc:date>
    </item>
  </channel>
</rss>

