BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ginak
Quartz | Level 8

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 Smiley Sad

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

2 REPLIES 2
Reeza
Super User

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;

ginak
Quartz | Level 8

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 688 views
  • 0 likes
  • 2 in conversation