BookmarkSubscribeRSS Feed
Deep81
Calcite | Level 5

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 CATEGORYFREQUENCYPERCENTAGE
.700019.7183
<15,0001250035.2113
15000 TO LESS THAN 250001100030.9859
25000 TO LESS THAN 35000500014.0845
TOTAL35500100

Surprisingly, this happens only for one variable. For the others, the missing values are successfully excluded.

Can anyone give any clue, please?

Thanks,

Deep

4 REPLIES 4
Haikuo
Onyx | Level 15

Because it is not missing, instead, it has the value of character '.'   . is missing for number, while for char, ' 'blank is considered as missing.

Deep81
Calcite | Level 5

Thanks, but actually it is . In the question I put the quotation marks just to emphasize that I used . instead of missing values.

Haikuo
Onyx | Level 15

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.

Tom
Super User Tom
Super User

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 548 views
  • 0 likes
  • 3 in conversation