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

is there way to find  all the Numeric variable and if obs is empty or . (dot), i want to replace all with Null value in one go 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26
Hi:
If you want to display a blank instead of a . for a missing numeric variable value, this is possible by using the MISSING= system option.
However, SAS internally stores missing values for numeric variables as a period/dot -- this is the internal representation of a missing value. SAS does not have the same concept of null values that you find in some databases or in a language like COBOL. I suggest you clarify what you mean by null values and where you want to change the values -- in an output report or in stored SAS data values.
Cynthia

View solution in original post

9 REPLIES 9
Cynthia_sas
Diamond | Level 26
Hi:
If you want to display a blank instead of a . for a missing numeric variable value, this is possible by using the MISSING= system option.
However, SAS internally stores missing values for numeric variables as a period/dot -- this is the internal representation of a missing value. SAS does not have the same concept of null values that you find in some databases or in a language like COBOL. I suggest you clarify what you mean by null values and where you want to change the values -- in an output report or in stored SAS data values.
Cynthia
animesh123
Obsidian | Level 7
I am trying to write the output into Flat file but when transferring into flat file am getting .(dot) am trying to replace with null value
animesh123
Obsidian | Level 7
NUll value means blank value
SASKiwi
PROC Star

Add this OPTIONS statement to the start of your program to write out blanks instead of dots in your flat file:

options missing = ' ';
Tom
Super User Tom
Super User

@animesh123 wrote:
I am trying to write the output into Flat file but when transferring into flat file am getting .(dot) am trying to replace with null value

Show the code you used to write the file.  Explain the layout you want in the file.

 

Note if you are writing a delimited file then the PUT statement should already be writing "null" (that is nothing at all) for missing values.  If it is writing whatever character you set with the MISSING option instead then you probably forgot to include the DSD option in the FILE statement.

animesh123
Obsidian | Level 7

I have dataset where the column is integer 

while writing this into flat file or in sasdataset i am getting .(dot) instead of populating null value,

same dataset when exporting into excel   using sas eg in there its coming blank

is there way to fix this to populate only Null for integer value rather than .(dot) also the same in text file where am writing into flat/text file

 

animesh123_0-1740170039339.png

 

Tom
Super User Tom
Super User

I do not understand what you are saying.   Actual data examples would help much more than photographs to explain what you are asking about.

 

In SAS a MISSING numeric value (which what I assume you mean by NULL) is represented in CODE by a period.   SAS also allows 27 other (special) missing values that are represented in CODE as a period followed by a single letter or the underscore character.

 

SAS will treat character variables that only contain spaces a missing.

 

When writing a numeric value to a text file using the default numeric format a normal missing value is represented by the character set with the MISSING= option.  The default character used by the missing option is a period.  Special missing values will be printed as letter used to represent them in the code.

 

When reading either a numeric or a character variable from a text file into SAS variables using the normal numeric or character informat a single period will be converted to a MISSING value.  To allow single letters to be read by the normal numeric informat as special missing values list those letters (or underscore) in the MISSING statement.  

 

See the documentation:

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p0ueqauvtyb2hqn1mj79t26azlxv.htm

 

Note also that when writing a text file use the DSD option on the FILE statement then missing values will take NO space in the text file.  The delimiters will be placed right next to each other.  To treat adjacent delimiters as indicating a missing value when reading a delimited text file make sure to include the DSD option on the INFILE statement.

ballardw
Super User

Are  you asking to see text that actually says NULL?

That would require custom formats to associate missing values, by default displayed with the dot, and might be a little bit tricky depending on individual variable attributes such as existing formats.

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

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 2011 views
  • 4 likes
  • 6 in conversation