BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ResoluteCarbon
Obsidian | Level 7

Hi all,

 

I am wondering what does Null stand for? Does it can be used to replace missing in both character and numeric data.

The background is that, the missing variable in character column is represented as " " while it is "." in numeric column. 

ResoluteCarbon_0-1617141516306.png

What I mean is, for the example above, whether we can wrote ?

where Age =null;

/*or*/

where Name = null;

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

@ResoluteCarbon wrote:

Hi all,

 

I am wondering what does Null stand for? Does it can be used to replace missing in both character and numeric data.

The background is that, the missing variable in character column is represented as " " while it is "." in numeric column. 

ResoluteCarbon_0-1617141516306.png

What I mean is, for the example above, whether we can wrote ?

where Age =null;

/*or*/

where Name = null;

Thank you!


NULL does NOT mean missing - it means a variable named "null".

 

Try 

where missing(varname);

The MISSING function works on both numeric and character variables.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

The keyword NULL has meaning in SQL.  It can be used to replace either numeric missing (the period) or all blank character string you would normally use in regular SAS code.

 

Because SAS consolidated the code/logic used to evaluate WHERE statements with the way they process SQL code you can use it in WHERE statements outside of PROC SQL. 

522   data x;
523    set sashelp.class;
524    where age is null;
525   run;

NOTE: There were 0 observations read from the data set SASHELP.CLASS.
      WHERE age is null;
NOTE: The data set WORK.X has 0 observations and 5 variables.

 

But if you use the string NULL in regular SAS statement it is just a reference to a variable with that name.

530   data z;
531    set sashelp.class;
532    if age = null ;
533   run;

NOTE: Variable null is uninitialized.
mkeintz
PROC Star

@ResoluteCarbon wrote:

Hi all,

 

I am wondering what does Null stand for? Does it can be used to replace missing in both character and numeric data.

The background is that, the missing variable in character column is represented as " " while it is "." in numeric column. 

ResoluteCarbon_0-1617141516306.png

What I mean is, for the example above, whether we can wrote ?

where Age =null;

/*or*/

where Name = null;

Thank you!


NULL does NOT mean missing - it means a variable named "null".

 

Try 

where missing(varname);

The MISSING function works on both numeric and character variables.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 975 views
  • 2 likes
  • 3 in conversation