BookmarkSubscribeRSS Feed
deleted_user
Not applicable
How can we distinguish a " " (blank) value with a null (missing) value for a character variable. Suppose I have a field in my input file with a field that can accept blank as a valid value:

Comma Delimited
Name (length = 20), At 25 Salary, Flag, Date of Birth (DDMntYY format),
Joe Williams, 70000, ,17Apr80
David Coleman, 91000,Y,29Nov70
Terrin Larson, 65000,F,01Jan00
Mathew Richardson, 85000,,02May78

There are number of missing values in this file. The last record has a missing value for the field "Flag", but the first record has a " " (blank) and valid value for this field. How can one read this file and capture the missing value distinguished from " " value?

I tried the below code for handling the subsequent ",". But don`t know how to know that the first record has a valid " " value for flag and the last record does not.

data MyLib.EmployeesWithFlag;
infile EmpFile dlm=',' firstobs=3 MissOver DSD;
length name $ 20.;
input name salary flag $ DoB Date7.;
run;

Thanks in advance for your taking time on this question.
Ramin
3 REPLIES 3
LinusH
Tourmaline | Level 20
I see your point. But if you want to store your flag as a character value, SAS does NOT distinguish between blank an MISSING/NULL, it's the same. In this case, would you consider to store any other value for your valid blank data?

If so, consider to read your whole record into one long string, and then use SAS character functions to find out if there is a blank or not between your delimeters.

Regards,
Linus
Data never sleeps
deleted_user
Not applicable
Hi Linus,
Thanks for your message. I think I understood your solution for strings manipluation, which is interesting.
Regards,
Ramin
deleted_user
Not applicable
I do not know whether I understand your question or not, I think it is the case to distinguish the space in the name and missing value. So why not use : modifier

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

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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