Hello,
I'm analyzing a dataset, which contains many variables with missing values. All the missing values are coded as ".". I do not want to include the missing values in analysis. However, for one of the variables, SAS keeps on including the missing values also in the table as if "." is a separate category, e.g.,
INCOME CATEGORY | FREQUENCY | PERCENTAGE |
---|---|---|
. | 7000 | 19.7183 |
<15,000 | 12500 | 35.2113 |
15000 TO LESS THAN 25000 | 11000 | 30.9859 |
25000 TO LESS THAN 35000 | 5000 | 14.0845 |
TOTAL | 35500 | 100 |
Surprisingly, this happens only for one variable. For the others, the missing values are successfully excluded.
Can anyone give any clue, please?
Thanks,
Deep
Because it is not missing, instead, it has the value of character '.' . is missing for number, while for char, ' 'blank is considered as missing.
Thanks, but actually it is . In the question I put the quotation marks just to emphasize that I used . instead of missing values.
Show me your data, and the way you use to exclude missing values. I did not get the idea from ".", rather, the way you present your data in your first post. You have put "." along with something like "15000 TO LESS THAN 25000", which obviously is char.
It is because your character variable has a period in it instead of being all blanks.
Either re-code the data or add a where clause to eliminate the observations were INCOME_CATEGORY='.' .
Try this little piece of code to see how CATEGORY and CATEGORY2 are treated differently.
data have ;
length income 8 category $20 freq 8 ;
infile cards dsd dlm='|';
input income category freq ;
category2=category;
if category2=' ' then category2='.';
cards;
.|.|7000
10000|<15,000|12500
20000|15000 TO LESS THAN 25000|11000
30000|25000 TO LESS THAN 35000|5000
run;
proc freq ;
tables income category category2 ;
weight freq ;
run;
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.
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.