DATA Step, Macro, Functions and more

Handling missing values or null value in raw data

Reply
N/A
Posts: 0

Handling missing values or null value in raw data

How can I handle the missing values in a field (VSTMD) thats a varchar datatype (sql table raw data) and that has to be written into a numeric SAS date field? Since it has "null" value, SAS considers as both character and numeric variable. How can this be resolved?
Super Contributor
Super Contributor
Posts: 3,174

Re: Handling missing values or null value in raw data

Posted in reply to deleted_user
A SAS variable is either CHARACTER or NUMERIC, in type. Normally the SAS CHARACTER type variable is either blank or non-blank, and a SAS NUMERIC type variable is either considered to have a MISSING value or a non-MISSING value.

Since SAS DATE / DATETIME variables are NUMERIC type, you can set a missing value, such as MYDATE=. or if you attempt to use the INPUT function to convert a string to a date and the input-data is invalid, SAS will set the automatic variable _ERROR_=1 which is an indication of a problem - in addition to SAS setting the variable to a missing value, as well.

There is a MISSING function you may find the opportunity to use - check the SAS DOC.

Also, suggest reviewing the DOC on SAS variables.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

sas variable missing value site:sas.com
Ask a Question
Discussion stats
  • 1 reply
  • 169 views
  • 0 likes
  • 2 in conversation