BookmarkSubscribeRSS Feed
Tanja
Calcite | Level 5

Hello Everyone!!

For the below dataset, I want to find the record where name is not null and gender is null.  Why if condition is not working .

data x;

input id name $ gender $;

cards;

101 rakesh kumar

102 . goyal

103 namita .

;

run;

data test1;

set x;

if name ne '' and gender eq '' then display="correct";

run;

Advance thanks

2 REPLIES 2
jakarman
Barite | Level 11

Would review the concepts of missing values: SAS(R) 9.4 Language Reference: Concepts and more in detail working with them. SAS(R) 9.4 Language Reference: Concepts  It is the . being used as default representation of missing with numeric variables. With character vars it is ' ' the space. Special missing are possible as sometimes you have more reasons that something is missing.

The usage of the word null is coming from a DBMS point of view that is not the same approach as missing in statistics.

When you are going for statistics try to see that difference and understand the origins.

Going to you question.

You have read the char-variables with "." content in the datastep.

That is really meaningful content for strings these are not missing values.  

---->-- ja karman --<-----
Tom
Super User Tom
Super User

What is doing that you do not want?

Obs    id     name     gender    display

1     101    rakesh    kumar

2     102              goyal

3     103    namita              correct

sas-innovate-2024.png

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.

 

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