Help using Base SAS procedures

Date format error?

Accepted Solution Solved
Reply
Super Contributor
Posts: 398
Accepted Solution

Date format error?

Hello,

 

I have imported code below.   But the log page showed error message below.  Please advice how to fix it.

 

Data residences;
      infile  "\\Pathway\ResidencesDates.csv" dlm="," dsd missover lrecl=32000 firstobs=2;
;
input 
      Id
      ResStartMM_1
      ResStartYY_1
      ResStopMM_1
      ResStopYY_1
	  ;
Format  ResStartMM_1 DateMM.;
Format  ResStartYY_1 DateYY.;
Format  ResStopMM_1 DateMM.;
Format  ResStopYY_1 DateYY.;
Label  ResStartMM_1="Residence Start Date Month";
Label  ResStartYY_1="Residence Start Date Year";
Label  ResStopMM_1="Residence Stop Date Month";
Label  ResStopYY_1="Residence Stop Date Year";
RUN;

 

The error message in the Log page:

 

45 Format ResStartMM_1 DateMM.;

                                          -------

                                          48

ERROR 48-59: The format DATEMM was not found or could not be loaded.

46 Format ResStartYY_1 DateYY.;

                                         -------

                                         48

ERROR 48-59: The format DATEYY was not found or could not be loaded.

47 Format ResStopMM_1 DateMM.;

                                          -------

                                          48

ERROR 48-59: The format DATEMM was not found or could not be loaded.

48 Format ResStopYY_1 DateYY.;

                                         -------

                                         48

ERROR 48-59: The format DATEYY was not found or could not be loaded.


Accepted Solutions
Solution
‎03-07-2018 10:35 AM
Super User
Posts: 6,751

Re: Date format error?

Months and years are numeric variables that don't need formats.

 

Are you trying to change how they are displayed?  If the answer is no, then just get rid of the format statements.

View solution in original post


All Replies
Solution
‎03-07-2018 10:35 AM
Super User
Posts: 6,751

Re: Date format error?

Months and years are numeric variables that don't need formats.

 

Are you trying to change how they are displayed?  If the answer is no, then just get rid of the format statements.

Super Contributor
Posts: 398

Re: Date format error?

I paste the code below again.

 

Data residences;

infile "\\Pathway\ResidencesDates.csv" dlm="," dsd missover lrecl=32000 firstobs=2;

;

input

Id

ResStartMM_1

ResStartYY_1

ResStopMM_1

ResStopYY_1

;

Format ResStartMM_1 DateMM.;

Format ResStartYY_1 DateYY.;

Format ResStopMM_1 DateMM.;

Format ResStopYY_1 DateYY.;

Label ResStartMM_1="Residence Start Date Month";

Label ResStartYY_1="Residence Start Date Year";

Label ResStopMM_1="Residence Stop Date Month";

Label ResStopYY_1="Residence Stop Date Year";

RUN;

 

Super Contributor
Posts: 398

Re: Date format error?

Below is my CSV file.  It's in the numbers was in general format in Excel.   I'm not sure if you could see that.

 

Id ResStartMM_1 ResStartYY_1 ResStopMM_1 ResStopYY_1
30005 2 1994 6 2001
SAS Employee
Posts: 199

Re: Date format error?

[ Edited ]

Hi @ybz12003

 

Those are not valid formats.

Try to use date9., etc. (cf https://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#n16vcb736tg...)

 

Hope that helps.


Cheers,
Damien

Super User
Super User
Posts: 9,599

Re: Date format error?

Super Contributor
Posts: 398

Re: Date format error?

Thank you all your prompt reply.  I got it fixed. 

☑ This topic is solved.

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

Discussion stats
  • 6 replies
  • 151 views
  • 0 likes
  • 4 in conversation