Help using Base SAS procedures

Why this date11. input date format and not DDMMYY10. ?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

Why this date11. input date format and not DDMMYY10. ?

I have the following txt file:

130.192.70.235 - - [08/Jun/2008:23:51:32 -0700] "GET /rover.jpg HTTP/1.1" 200 66820

128.32.236.8 - - [08/Jun/2008:23:51:40 -0700] "GET /grooming.html HTTP/1.0" 200 8471

128.32.236.8 - - [08/Jun/2008:23:51:40 -0700] "GET /Icons/brush.gif HTTP/1.0" 200 89

128.32.236.8 - - [08/Jun/2008:23:51:40 -0700] "GET /H_poodle.gif HTTP/1.0" 200 1852

118.171.121.37 - - [08/Jun/2008:23:56:46 -0700] "GET /bath.gif HTTP/1.0" 200 14079

128.123.121.37 - - [09/Jun/2008:00:57:49 -0700] "GET /lobo.gif HTTP/1.0" 200 18312

128.123.121.37 - - [09/Jun/2008:00:57:49 -0700] "GET /statemnt.htm HTTP/1.0" 200 238

128.75.226.8 - - [09/Jun/2008:01:59:40 -0700] "GET /Icons/leash.gif HTTP/1.0" 200 98

Now I want to read in the data, let's focus on the date. The correct solution is:

data newdata2;

    infile 'D:\SAS\Messy Data.txt';

    Input @'[' AccessDate Date11. ;

run;

However, I thought that this is correct:

data newdata2;

    infile 'D:\SAS\Messy Data.txt';

    Input @'[' AccessDate DDMMYY10. ;

run;

I am not sure about the 10, but at least I thought it has to be the DDMMYY format, because in the txt file, the format of the date values is dd/mm/yyyy. But when I use date11., I thought it should be in something like 1jan1961.

So why do I have to use date and not ddmmyy?

Thanks a lot for your help!


Accepted Solutions
Solution
‎04-20-2015 02:50 AM
Super User
Posts: 7,854

Re: Why this date11. input date format and not DDMMYY10. ?

When you have the Month written as a three-letter word, the correct format to use ist the DATE. format. DDMMYY. is for numerical values only (31/12/2008)

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎04-20-2015 02:50 AM
Super User
Posts: 7,854

Re: Why this date11. input date format and not DDMMYY10. ?

When you have the Month written as a three-letter word, the correct format to use ist the DATE. format. DDMMYY. is for numerical values only (31/12/2008)

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 11,343

Re: Why this date11. input date format and not DDMMYY10. ?

There are a largish number of Informats available as there are many different ways that people/systems will write dates.
DATETIME, ANYDTDTE or ANYDTDETM would also have worked with the appropriate width specified with the understanding that you could have datetime variable or a date variable.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 568 views
  • 5 likes
  • 3 in conversation