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

hi, I am trying to set all missing values in the last_review column to 0. I tried to use this code however I am getting a date which is 01/01/1960 when I am expecting to get the value 0. How do I change the date given to put 0.

 

code: 

proc sql;
update WORK.IMPORT
set
last_review = 0
where
last_review is missing;
quit;

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
4 REPLIES 4
Kurt_Bremser
Super User

A value of 0 in a variable used to store dates will result in 1960-01-01, as that is day zero on the SAS date scale.

"Unknown" must be stored as a missing value.

Ngo99
Fluorite | Level 6
thank you
PaigeMiller
Diamond | Level 26

Good advice from @Kurt_Bremser 

 

In addition:

 

Changing missing values to an actual number (without good reason) is something to be avoided. It makes mathematical operations — such as taking an average — incorrect. And of course, usually, it is extra work that provides no benefit, something else to be avoided.

--
Paige Miller
ballardw
Super User

Hint: Missing values are easy to display in reports by using the options statement:

 

Options missing='0';

This will, until reset, display all missing values as 0 instead of . in output such as Procs Report or Print.

 

Another is to use a custom format. And example for your variable, since it is apparently a date value might look like:

proc format;
value mycustomdate
. = "N/A"
other = [date9.]
;
run;

and use the Mycustomdate format instead of the current one. Use your current date format in the [ ] brackets above if using something other than date9. You can display any text you want for the missing values though I would keep it short and relevant to the dates use. The brackets coupled with the keyword Other in Proc format means all values not in another value range are displayed with the format in the brackets.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1930 views
  • 1 like
  • 4 in conversation