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

Hi guys, 

 

My data tables has about 1,000 records with the following variables:

Name

Age

City

State

MonthlyBill

 

I am using the following code to remove retain those who are from NY and pays monthly of $500 or less

 

proc sql;
create table want as
select t1.*
from have t1
where t1.state IN ('NY') 
and t1.MonthlyBill lt 500;
quit;

I am left with 300 records and I am confused. Upon checking, my tables have about 200 NY customers and 500 are those below 500 bill. I was only expecting about 200 to be removed.

 

Any thoughts?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Your description is confusing.  Your code is not "removing" anything. It is selecting just the observations that meet both criteria.

So if there are only 200 NY records then the maximum number of observations you will get is 200.  If any of them have bills larger than 500 then you will get less than 200.  Remember that SAS will treat missing values as less than any actual number so your WANT dataset could include observations with missing values for monthlybill

 

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Your description is confusing.  Your code is not "removing" anything. It is selecting just the observations that meet both criteria.

So if there are only 200 NY records then the maximum number of observations you will get is 200.  If any of them have bills larger than 500 then you will get less than 200.  Remember that SAS will treat missing values as less than any actual number so your WANT dataset could include observations with missing values for monthlybill

 

rapt1
Obsidian | Level 7

Oh. Let me revisit my code. Thanks!

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
  • 610 views
  • 1 like
  • 2 in conversation