SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Format DATE9

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Format DATE9

Im reading some data from a file where the data is in the format 01DEC2010 which actually is the format date9 in SAS. I must read the data from the file and create a table specifiying that the format must be DATE9 but when i try to do so, at my table there is only a "." at the date columnn.

here is the sintax im using:

data maria;

infile 'C:\Users\Cesar\Desktop\tpnote\ssd.dat';

input idvol $ 1-7  @40 datevol DATE9.   @64 totalpass 65-67 @68 poidscargo 69-73;

run;

and here are some lines from the file:

IA112000000112SFOHNDJetCruise LF810001DEC1999 4  19  31 171 255 61300 79077
IA018040000018SFOSEAJetCruise SF100001DEC1999 4  10       123 150 10300 13287
IA029010000029SFOHNLJetCruise LF520002DEC1999 5  13  24 138 207 47400 61146

Can someone help me please?


Accepted Solutions
Solution
‎02-15-2014 10:46 AM
Super User
Super User
Posts: 6,502

Re: Format DATE9

Actually there are tabs before the date so the date is NOT in column 40.

If you are using the INFILE option EXPANDTABS then the date will start in column 41.

IA112000000112SFOHNDJetCruise LF8100    01DEC1999 4  19  31 171 255 61300 79077

IA018040000018SFOSEAJetCruise SF1000    01DEC1999 4  10       123 150 10300 13287

IA029010000029SFOHNLJetCruise LF5200    02DEC1999 5  13  24 138 207 47400 61146

Plus the second line is not going to align for reading the later columns.  Since they are separated by spaces anyway I recommend replacing the missing values with period and use list mode input.

IA112000000112SFOHNDJetCruise LF8100    01DEC1999 4  19  31 171 255 61300 79077

IA018040000018SFOSEAJetCruise SF1000    01DEC1999 4  10   . 123 150 10300 13287

IA029010000029SFOHNLJetCruise LF5200    02DEC1999 5  13  24 138 207 47400 61146

View solution in original post


All Replies
Respected Advisor
Posts: 3,777

Re: Format DATE9

Need more information notes from log.  When I copy your records to an editor there are two '0a'x between LF8100 and 01DEC1999 by default SAS will use '0a' as new line.  So  datevol ain't @40.

Frequent Contributor
Posts: 83

Re: Format DATE9

cesartiburcio,

I think the problem is that you are trying to tell it to input a date without specifying some information beforehand. To get the format to be read in correctly and applied I think you will need to specify a length, informat, and format as well as the input statement. Below is some code that should import it correctly.

data maria;

length idvol $7. datevol 8 totalpass 3 poidscargo 5;

informat idvol $7. datevol date9. totalpass BEST3. poidscargo BEST5.;

format idvol $7. datevol date9. totalpass BEST3. poidscargo BEST5.;

infile 'C:\Users\Cesar\Desktop\tpnote\ssd.dat';

input @1 idvol $1-7  @40 datevol date9. @64 totalpass BEST3. @68 poidscargo BEST5.;

run;

Also make sure that the pointers are going to the right places. When I pulled your data off of your post, the date actually started at 38, but it may have just been the way that I copied and pasted.

Hope this helps

Solution
‎02-15-2014 10:46 AM
Super User
Super User
Posts: 6,502

Re: Format DATE9

Actually there are tabs before the date so the date is NOT in column 40.

If you are using the INFILE option EXPANDTABS then the date will start in column 41.

IA112000000112SFOHNDJetCruise LF8100    01DEC1999 4  19  31 171 255 61300 79077

IA018040000018SFOSEAJetCruise SF1000    01DEC1999 4  10       123 150 10300 13287

IA029010000029SFOHNLJetCruise LF5200    02DEC1999 5  13  24 138 207 47400 61146

Plus the second line is not going to align for reading the later columns.  Since they are separated by spaces anyway I recommend replacing the missing values with period and use list mode input.

IA112000000112SFOHNDJetCruise LF8100    01DEC1999 4  19  31 171 255 61300 79077

IA018040000018SFOSEAJetCruise SF1000    01DEC1999 4  10   . 123 150 10300 13287

IA029010000029SFOHNLJetCruise LF5200    02DEC1999 5  13  24 138 207 47400 61146

New Contributor
Posts: 2

Re: Format DATE9

Yes that was the only problem. the column is the column 41. thanks

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 494 views
  • 6 likes
  • 4 in conversation