BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8

when you create a variable and have not assigned value to it , does it equals to "null" or zero?

 

4 REPLIES 4
HeatherNewton
Quartz | Level 8

so if it is a number it is "." which means missing 

if strange, it is empty so it is null?

ballardw
Super User

Suggest that when working with SAS and missing values that you do not think of "NULL" or "empty". Because you can have more than one missing value for numeric variables. Besides the default displayed dot (and that is YOUR option to change as needed) there are special missing values .A to .Z (dot and one letter) and the underscore: ._   So there is something stored to differentiate these values, they all return missing when tested but can display differently.

 

One use for the special missing values is to show a known reason for the value to be missing in variable.

Example. The first data step creates set with one numeric value and some special missing. Then uses Proc Means to provide some requested statistics, note the number of NMISS, number of missing values. Then a custom format is created to provide a meaning for the special missing and proc print to demonstrate the use of that format with the example data set.

data example;
   input x;
datalines;
1
.A
.B
.C
.D
;

proc means data=example n nmiss sum;
   var x;
run;

Proc format;
value mycustommiss
.A = 'Not answered'
.B = 'Broken instrument'
.C = 'Cancelled request'
.D = "Don't Know"
;

proc print data=example;
   var x;
   format x mycustommiss.;
run;

And to head off questions about character variables and special missing, no. Reading values like .A into a character variable results in the character value of .A.

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 4 replies
  • 897 views
  • 1 like
  • 3 in conversation