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 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 |
Can someone help me please?
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
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.
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
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
Yes that was the only problem. the column is the column 41. thanks
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.