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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

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