turn on suggestions

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

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- How to delete answers/entries in SAS

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2012 07:45 PM

Hello, I am not sure how to correctly phrase my question into a simple subject line.

Basically, I have a survey Question "What is the number of graduate courses you took for training?"

and I have as answers:

0 frequency: 47

1 frequency: 7

2 frequency: 4

3 frequency: 2

6 frequency: 1

I want to do a PROC MEANS on this variable, NUM_CLASSES. So I already did that, I get a mean of 0.4.

Here is my question: I want to get rid of all 47 of the 0's and run a PROC MEANS on NUM_CLASSES without the 0's. How can I do so? I was thinking of creating a new variable in a DATA step and somehow writing a for loop indicating to get rid of the 0's.

Thank you so much! I figure it is relatively simple, but I'm having trouble figuring it out

Accepted Solutions

Solution

03-10-2012
08:03 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2012 08:03 PM

Use a where statement to exclude observations.

Assuming your variables are:

num_classes - number of class, freq - count (ie 47, 7)

proc means data=have;

var num_classes;

weight freq;

run;

proc means data=have;

where num_classes>0;

var num_classes;

weight freq;

run;

All Replies

Solution

03-10-2012
08:03 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2012 08:03 PM

Use a where statement to exclude observations.

Assuming your variables are:

num_classes - number of class, freq - count (ie 47, 7)

proc means data=have;

var num_classes;

weight freq;

run;

proc means data=have;

where num_classes>0;

var num_classes;

weight freq;

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-10-2012 09:24 PM

thank you! The freq part didn't work , so I commented it out and the rest of the code worked Thanks!