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.

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 395 views
  • 1 like
  • 3 in conversation