In general your code looks correct so are you sure it didn't work?
You need to look at the type and format, the informat of a variable isn't particularly useful unless you're reading in the data. You should remove your INFORMAT statement or change it to a FORMAT statement. If you do have a datetime as suggested by @PaigeMiller you can use the DATEPART() function to get just the date for the comparison.
data work.test1_hctz;
set work.test_hctz;
if hctzdate ='03JAN2007'd then hctzdate=.;
format hctzdate ddmmyy10.;
run;
@wottma wrote:
Hi SAS-Community,
I have a date variable (informat ddmmyy10.) called hctzdate. I am trying to replace one specific date with a missing value (a '.'). In my example I would like to replace the date 03/01/2007.
How can I do that?
I tried:
data work.test1_hctz; set work.test_hctz;
if hctzdate ='03jan2007'd then hctzdate=.;
informat hctzdate ddmmyy10.;
run;
There wasn't an error in the log file, however nothing happened when I looked at the data in the viewtable. I am using SAS 9.4. Can anyone help me?
Thanks a lot in advance 🙂