hi all,
try to infile a list of date and by default it was set to 00/00/00, when i execute 00/00/00 will become missing value as it is a invalid date. Can it extract as a date 00/00/00 instead of missing value?
data testing;
infile datalines dlm='|';
input h :ddmmyy. g :ddmmyy.;
format h g ddmmyy8.;
datalines;
10/12/07 | 10/01/16
00/00/00 | 28/03/17
;
please advice.
You can't save 00/00/00 as a date, because it isn't a date. However, you can create your own format for display purposes. For example:
proc format;
value mydate .='00/00/00' other=[ddmmyy8.];
run;
Then when using the data, apply the format:
format h g mydate.;
Just one final word, though. After the billions of dollars spent overcoming problems with two-digit years, why wouldn't you choose a format that permits four-digit years?
What date do you want to use instead of missing? No day of the month, no month of the year = not a date. So the value cannot be represented as a date.
What will you do with those date variables later on?
proc format;
invalue fmtdte
'00/00/00' =-9E99
other = [ddmmyy.]
;
run;quit;
data testing;
informat h fmtdte.;
input h ;
cards4;
10/12/07
00/00/00
;;;;
run;quit;
Up to 40 obs WORK.TESTING total obs=2
Obs H
1 17510
2 -9E99
or
Up to 40 obs WORK.TESTING total obs=2
Obs H
1 17510
2 0
I think that an Informat/ Format solution may work better with the special missing
proc format;
invalue fmtdte
'00/00/00'= .A
other =[ddmmyy8.];
value mydate
.A='00/00/00'
other=[ddmmyy8.];
run;
Use of any value may run into issues with date functions.
You can't save 00/00/00 as a date, because it isn't a date. However, you can create your own format for display purposes. For example:
proc format;
value mydate .='00/00/00' other=[ddmmyy8.];
run;
Then when using the data, apply the format:
format h g mydate.;
Just one final word, though. After the billions of dollars spent overcoming problems with two-digit years, why wouldn't you choose a format that permits four-digit years?
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.