do you know if sas automatically turn null into 0 in any case?
in what I see, when sas read in from files other than sas dataset
it turn null into zero
why is this??
our files are iff, lets say it is some text file
Assuming by "null", you mean a blank character, and assuming you are reading values via the INPUT statement, then SAS does NOT by default convert a null into a zero (we are discussing numeric variables here). Instead, the numeric variable is assigned a special missing value (typically printed out as a naked period), when read from a "null".
I.e. this program:
data t;
input @1 x 1. @3 y 1. ;
put (_all_) (=);
datalines;
1 1
2
3
run;
produces this on the sas log (note the dots).
x=1 y=1
x=2 y=.
x=. y=3
NOTE: The data set WORK.T has 3 observations and 2 variables.
A missing value, by default, is not treated as a zero, although there are some SAS functions and statements that can treat missing values as zeroes.
If a data step is used to read the files, a custom informat could change missing (aka null) to 0 automatically.
Hi,
Please share an example data step with instream data (e.g., datalines), so that we can replicate the issue to assist with a solution.
Depending upon how you are reading in the data and viewing it, the missing= option might be worth checking, as the page says "Specifies the character to print for missing numeric values."
Thanks & kind regards,
Amir.
@HeatherNewton wrote:
do you know if sas automatically turn null into 0 in any case?
in what I see, when sas read in from files other than sas dataset
it turn null into zero
why is this??
our files are iff, lets say it is some text file
What is your current setting for the MISSING option? You can check by running this code:
Proc options option=missing; run;
The output in the log will look something like:
49 Proc options option=missing; 50 run; SAS (r) Proprietary Software Release 9.4 MISSING=. Specifies the character to print for missing numeric values.
If your result shows Missing=0 then your setting is displaying zero when the value is missing.
Otherwise show the code you are using to read one of these files and a few lines of the text file data that exhibit this behavior.
Unless you have subject matter knowledge that allows you to know that null should be treated as zeros, do NOT do this. Nulls should be treated as missing without such subject matter knowledge.
@HeatherNewton please mark one of the above replies as correct, whichever one you think is correct.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.