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

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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