date format problem error 48-59

Reply
N/A
Posts: 0

date format problem error 48-59

How can i fix this problem ?
data infile a.txt
AAA,13000,14/5/1978,32,MR,1,6,A
BBB,30000,25/7/1955,52,MR,1,12,B
CCC,12000,3/5/1978,29,MRS,0,12,C

data f11;
length d1 $10.;
infile "d:\DATA\a.txt" dlm =',' ;
input status $ salary d1 ddmmyy10. age title $ gender duration mar $ ;
run;

ERROR 48-59: The format $MMDDYY was not found or could not be loaded

thanks in advance.
Super Contributor
Posts: 260

Re: date format problem error 48-59

Hi Photo.
First you have to drop the LENGTH statement : it's telling SAS that the D1 variable is character type -- which obviously it is not, since it's a date. If you want the dates stored as character (preventing the use of SAS date functions), see point 3.
Second you have to add : before the DDMMYY informat in the INPUT statement, since the total length of the dates is not always the same (from 8 to 10). The 10 figure at the end of the informat will then be considered as the maximum length of data to read before delimiter.
Third, if you want to get D1 as a character variable, replace the Smiley Very HappyDMMYY10. informat for D1 for :$10. and you don't even need the LENGTH statement anyway.
That would lead to : [pre]

data f11;
infile cards dlm =',' ;
input status $ salary d1 :ddmmyy10. age title $ gender duration mar $ ;
format d1 ddmmyy10. ;
cards ;
AAA,13000,14/5/1978,32,MR,1,6,A
BBB,30000,25/7/1955,52,MR,1,12,B
CCC,12000,3/5/1978,29,MRS,0,12,C
;
run;[/pre]
or
[pre]
data f11;
infile cards dlm =',' ;
input status $ salary d1 :$10. age title $ gender duration mar $ ;
cards ;
AAA,13000,14/5/1978,32,MR,1,6,A
BBB,30000,25/7/1955,52,MR,1,12,B
CCC,12000,3/5/1978,29,MRS,0,12,C
;
run;[/pre]
Regards,
Olivier
Ask a Question
Discussion stats
  • 1 reply
  • 2525 views
  • 0 likes
  • 2 in conversation