BookmarkSubscribeRSS Feed
ljljlj
Calcite | Level 5

Hello, I need to use proc means only for rows that meet two criteria. For example:

 

pre   post    dif

1        0          -1

0       4           4

3       2           -1

0       0           0

5       5           0

 

I'd like to run proc means and exclude the 4th row.

I've tried using "where A ne 0 and B ne 0" and where "A ne 0 or B ne 0" and neither provide the correct output. Any help would be greatly appreciated!

 

Unsuccessful code:

proc means data=ABC mean sum;

var pre post dif;

where pre ne 0 and post ne 0;

run;

 

proc means data=ABC mean sum;

var pre post dif;

where pre ne 0 or post ne 0;

run;

 

 

2 REPLIES 2
PaigeMiller
Diamond | Level 26

I'd like to run proc means and exclude the 4th row.

 

	where not (pre eq 0 and post eq 0);

Alternatively

where (pre ne 0) or (post ne 0);

Your last code works for me.

--
Paige Miller
ballardw
Super User

Provide example output for a given input set and describe why it is incorrect, especially for that second proc means code as @PaigeMiller indicates.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 590 views
  • 0 likes
  • 3 in conversation