BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sagulolo
Quartz | Level 8

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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?

View solution in original post

7 REPLIES 7
ballardw
Super User

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?

sagulolo
Quartz | Level 8
thank for your time ballardw,

actually the date was recorded as an incident happen, eg payment date, transaction date etc. if 00/00/00 means no transaction or payment was made.

Best Regards
sagulolo
Quartz | Level 8
Possible to put it as 00/00/00 string since 00/00/00 is not a valid date?
rogerjdeangelis
Barite | Level 11

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



ballardw
Super User

@rogerjdeangelis

 

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.

  

Astounding
PROC Star

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?

sagulolo
Quartz | Level 8
Thank you so much Astounding,
for your question, just wanted to import to SAS according to the original text format. Or maybe in future, it might change to four-digit years.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1548 views
  • 0 likes
  • 4 in conversation