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;
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.
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.
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.