BookmarkSubscribeRSS Feed
shlomiohana
Obsidian | Level 7

Hello,

 

In the table shown I use proc mean and I want when the field number_card =7777 the record will be taken into account but will not be counted in the number of records.

For example in this table, the proc mean will be count 4 records.

Is it possible?

 

table:

bankbranchnumber_cardgroupcompany
20133378789222
20133335345331
2017777551
20244454534222
2027777331
20244434535551

 

Proc Means Data=SASHelp.cars;

class branch;
Var group;

Run;

 

And I'll get something like that:

branchN  Obsgroup
112
113
105
212
203
215

 

Thanks.

1 REPLY 1
Tom
Super User Tom
Super User

Sounds like you just want to add a WHERE statement to exclude those observations.

Clearly your dataset is not named SASHELP.CARS.  Let's assume it is named HAVE instead.

Do you want the MEAN of GROUP?  That doesn't make much sense unless the GROUP variable has the number of people in the group?  Looks more like you want to use GROUP as another CLASS variable.

Assuming number_card is a character variable then the code could look like:

 

proc means data=HAVE ;
  where number_card ne '7777';
  class branch group;
run;

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 598 views
  • 0 likes
  • 2 in conversation