DATA Step, Macro, Functions and more

Set all Empty variables to Missing Values ?

Posts: 42

Set all Empty variables to Missing Values ?

Dear All,

I would like to write a program to read a file set all empty variables to missing values. Is it possible in SAS ?

Thanks a lot in advace for help and appreciate for the same.


S Ravuri.

Posts: 9,371

Set all Empty variables to Missing Values ?

Posted in reply to sambasiva_ravuri_tcs_com


  I'm not sure what you mean when you says that you want to "read a file" and "set all empty variables to missing values". It is very possible in SAS to do what you ask, but the question is, what does your input file look like? Is it comma delimited, tab delimited, or a sequential file, such as created on the mainframe? Is it a file where all the daa is in fixed columns?

  How do you know that there are "empty variables" in the original input file?

  Can you post a sample of your data and the program that you have tried? For example, if you had a comma-separated file like this, with 3 variables and 4 rows, then:



"Anna Marie",,chocolate

"Billy Bob",22,



then, for the first data row (Anna Marie) does not have a value for AGE, so you could say that AGE is "empty" -- but SAS can correctly read the 2 commas next to each other as a missing value for AGE. Likewise, the 3rd data row -- for the 23 year old person who likes raspberry -- does not have any value for NAME. And, SAS can read this data and set name to missing (which will be represented as a blank for character variables).

Without knowing what your data looks like and what you mean by "empty", it is nearly impossible to make coding suggestions. Have you tried PROC IMPORT? Have you tried a DATA step program with an INFILE and INPUT statement?


Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation