Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- Need Help on Using Countif in SAS

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 07-23-2016 08:28 PM
(1979 views)

1 = Yes

0 = No

Given that I have the data set as shown, I'd like to accomplish the following tasks

1.) What is the percentage of the insured with high-school education have an accident?

Ans... 3/4 = 75%

2.) How many married insured have an accident?

Ans... 1/3 = 33%

It would be relatively simple in Excel. But I'm quite new to SAS.

Would you please help me?

PS I use SAS Academics On-Demand.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

6 REPLIES 6

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hmm...there's quite a few ways. What do you want your output to look like?

One quick way is proc freq.

```
proc freq data=have;
table accident*education; /*Question 1*/
table married*accident;/*Question 2*/
run;
```

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.

PS. Please post data samples as text, I won't type out your data to test any solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Here's something to think about with 0/1 coded variables as shown as long as they are actually numeric:

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.

Yet another procedure:

proc tabulate data=have;

var accident married HSEd;

tables accident='Have an accident' married='Married?' HSED='High School Education' ,

sum='Count'*f=best4. Mean='Percent'*f=percent8.0;

run;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thank you

Are you ready for the spotlight? We're accepting content ideas for **SAS Innovate 2025** to be held May 6-9 in Orlando, FL. The call is **open **until September 25. Read more here about **why** you should contribute and **what is in it** for you!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.