BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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.
1 REPLY 1
Olivier
Pyrite | Level 9
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 :DDMMYY10. 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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 1 reply
  • 5058 views
  • 0 likes
  • 2 in conversation