BookmarkSubscribeRSS Feed
maciulei
Fluorite | Level 6

Hi,

I am dealing with an error that produces 0 observations in my newly formed data set once I use "then delete" statement for missing data or if I want to delete unusual values. Why would that be? I pasted the code below. 

 

Thanks!

 

data NHANES05.cycle_full;
set NHANES05.NHANES_0506_full_b;
/*Poverty Income Ratio*/
if INDFMPIR<=0.99 then poorcat1=1; else poorcat1=0;
if INDFMPIR>1 and INDFMPIR<=1.99 then poorcat2=1; else poorcat2=0;
if INDFMPIR>2 and INDFMPIR<=2.99 then poorcat3=1; else poorcat3=0;
if INDFMPIR>3 and INDFMPIR<=3.99 then poorcat4=1; else poorcat4=0;
if INDFMPIR>4 and INDFMPIR<=4.99 then poorcat5=1; else poorcat5=0;
if INDFMPIR>5 then poorcat6=1; else poorcat6=0;
if INDFMPIR=. then poorcat=.;

run;

 

**delete missing data;
data NHANES05.cycle_full_a;
set NHANES05.cycle_full;

/*Poverty Income Ratio*/
if INDFMPIR>=0 and INDFMPIR<=5 then poor1=1; else poor1=0;
if INDFMPIR=. then delete; *none based on this code but outside of the 0-5, N=72 coded as missing;

run;

5 REPLIES 5
unison
Lapis Lazuli | Level 10

A few things, when you do "<=0.99" that is different than later when you specify ">=0". Also, I think you may have observations that are exactly equal to 1,2,3,4,5 but your bucketing does not capture them.

 

Given that I think you are trying to bucket the observations, I would use proc format instead. (if you don't want to include 1, 2, 3, etc. change 1-1.99 to 1<-1.99, 2-2.99 to 2<-2.99 etc.)

 

proc format;
	value poorcat low-0.99=1 1-1.99=2 2-2.99=3 3-3.99=4 4-4.99=5 5-5.99=6 other=0;
run;

data have;
	set sashelp.syr1001(keep=S0666);
	poor_cat=put(S0666, poorcat.);
run;

data want;
	set have;
	if poor_cat ne 0;
run;

-unison

-unison
Astounding
PROC Star
Your program uses INDFMPIR but doesn't change it in any way.

Therefore you need to go back to your original data set and look for missing values there.

Perhaps the incoming values for INDFMPIR are incorrect.
maciulei
Fluorite | Level 6
I checked the log and one of the imported files gave the error that the file is sequential in red. I fixed the issue by checking the file location, which was wrong. Now everything works!
Kurt_Bremser
Super User

@maciulei wrote:
I checked the log and one of the imported files gave the error that the file is sequential in red. I fixed the issue by checking the file location, which was wrong. Now everything works!

That's why Maxim 2 is so high up on the list.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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
  • 5 replies
  • 600 views
  • 4 likes
  • 4 in conversation