<?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: Need Help on Using Countif in SAS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286621#M59511</link>
    <description>&lt;PRE&gt;
You'd better post your data as TEXT form. No one would like to type it for you .


data have;
input index accident married highschool;
cards;
1 1 0 1
2 1 0 1
3 0 1 1
4 0 1 0
5 1 1 1
;
run;
proc sql;
select sum(accident)/count(*) as per from have where highschool=1;
select sum(accident)/count(*) as per from have where married=1;
quit;


&lt;/PRE&gt;</description>
    <pubDate>Sun, 24 Jul 2016 02:03:28 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-07-24T02:03:28Z</dc:date>
    <item>
      <title>Need Help on Using Countif in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286615#M59509</link>
      <description>&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4194i8E2FB7B00C59E4FD/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Countif SAS.png" title="Countif SAS.png" /&gt;&lt;/P&gt;&lt;P&gt;1 = Yes&lt;/P&gt;&lt;P&gt;0 = No&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given that I have the data set as shown, I'd like to accomplish the following tasks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.) What is the percentage of the insured with high-school education have an accident?&lt;/P&gt;&lt;P&gt;Ans... 3/4 = 75%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.) How many married insured have an accident?&lt;/P&gt;&lt;P&gt;Ans... 1/3 = 33%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be relatively simple in Excel. But I'm quite new to SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you please help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS I use SAS Academics On-Demand.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jul 2016 00:28:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286615#M59509</guid>
      <dc:creator>momeya</dc:creator>
      <dc:date>2016-07-24T00:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help on Using Countif in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286617#M59510</link>
      <description>&lt;P&gt;Hmm...there's quite a few ways. What do you want your output to look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One quick way is proc freq.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
table accident*education; /*Question 1*/
table married*accident;/*Question 2*/
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You have to read the correct cell from the output. If you want something more specific you need to post more details on expected output as well as sample data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS. Please post data samples as text, I won't type out your data to test any solution.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jul 2016 01:36:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286617#M59510</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-24T01:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help on Using Countif in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286621#M59511</link>
      <description>&lt;PRE&gt;
You'd better post your data as TEXT form. No one would like to type it for you .


data have;
input index accident married highschool;
cards;
1 1 0 1
2 1 0 1
3 0 1 1
4 0 1 0
5 1 1 1
;
run;
proc sql;
select sum(accident)/count(*) as per from have where highschool=1;
select sum(accident)/count(*) as per from have where married=1;
quit;


&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Jul 2016 02:03:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286621#M59511</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-24T02:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help on Using Countif in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286745#M59515</link>
      <description>&lt;P&gt;Here's something to think about with 0/1 coded variables as shown as long as they are actually numeric:&lt;/P&gt;
&lt;P&gt;The SUM would give you the number of answers coded 1, Mean gives the percentage (though it will require either multiplication by 100 OR , much better, use of a SAS PERCENT format for display.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yet another procedure:&lt;/P&gt;
&lt;P&gt;proc tabulate data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var accident married HSEd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; tables accident='Have an accident' married='Married?' HSED='High School Education' ,&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; sum='Count'*f=best4. Mean='Percent'*f=percent8.0;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 02:43:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286745#M59515</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-25T02:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help on Using Countif in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286751#M59516</link>
      <description>Thank you!</description>
      <pubDate>Mon, 25 Jul 2016 03:46:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286751#M59516</guid>
      <dc:creator>momeya</dc:creator>
      <dc:date>2016-07-25T03:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help on Using Countif in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286752#M59517</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 03:47:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286752#M59517</guid>
      <dc:creator>momeya</dc:creator>
      <dc:date>2016-07-25T03:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help on Using Countif in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286753#M59518</link>
      <description>&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 03:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-Help-on-Using-Countif-in-SAS/m-p/286753#M59518</guid>
      <dc:creator>momeya</dc:creator>
      <dc:date>2016-07-25T03:47:56Z</dc:date>
    </item>
  </channel>
</rss>

