It's easy enough to change your code:
if var in (' ', '00'x) then x1=1;
else x1=0;
There are complications, however, if your variable is defined as being more than one character long. For example, if your variable is 5 characters long, you might actually have 5 nulls there, rather than one null with four blanks. The logic above wouldn't pick up 5 nulls.
For longer variables, another variation would be:
if var in : (' ', '00'x) then x1=1;
else x1=0;
This will compare just the first character of your variable, looking for blanks and nulls. That may be acceptable, but it depends on whether you might have data values that begin with a blank (or a null) but contain actual text afterwards.
The tools are there, it's really a matter of knowing what's in the data. Your best bet might be to forget about creating X1. Just use the TRANSLATE function to convert all nulls into blanks. That would certainly make later programming easier as well.
***** EDITED: I see that Tom already posted the syntax for TRANSLATE, as I was typing my answer.
... View more