Help using Base SAS procedures

Informat date not processing correctly

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Informat date not processing correctly

Hello All!

I need some help. I'm trying to have SAS read Nonstandard data from a comma-delimited raw data file, and no matter what I do it will not process the date correctly. The issue is with the BirthDate data, the raw file has them formatted DD/MM/YYYY. I specified on the input statement to have BirthDate:ddmmyy10.  but SAS is processing all the date outputs as JAN1960 or DEC1959. For example, one of the raw birth dates is 16/10/1986 but SAS is displaying it as JAN1960. Below is my code, partial output, and the raw data. Can anyone see what I am doing wrong?

Here is my code:

data work.customers;

  infile "/folders/myfolders/Data1/custca.csv"

  dlm=',';

  input First :$20. Last :$20. ID

  Gender :$1. BirthDate:ddmmyy10. Age AgeGroup :$12.;

  drop ID Age;

  format BirthDate DTMONYY7.;

  label BirthDate='Birth*Date';

run;

proc print data=work.customers label;

run;

proc contents data=work.customers varnum;

run;

Here is a partial output:

Customers

1BillXXXXXMJAN196015-30 years
2SusanXXXXXFDEC195946-60 years
3AndreasXXXXXMDEC195961-75 years

                                                                                                                      Variables in Creation Order

                                                                                                                                                                            Format           Informat         Label

1FirstChar20
2LastChar20
3GenderChar1
4BirthDateNum8DTMONYY7.DDMMYY10.Birth*Date
5AgeGroupChar12

                


Here is the raw data file edited with X's for this thread: (it is a csv file)

Bill,XXXXX,IDXXXX,M,16/10/1986,21,15-30 years                                   

Susan,XXXXX,IDXXXX,F,09/07/1959,48,46-60 years                          

Andreas,XXXXX,IDXXXX,M,18/07/1934,73,61-75 years                           

Lauren,XXXXX,IDXXXX,F,24/10/1986,21,15-30 years                         

Lauren,XXXXX,IDXXXX,F,18/08/1969,38,31-45 years                              

Tommy,XXXXX,IDXXXX,M,20/01/1959,48,46-60 years                           

Colin,XXXXX,IDXXXX,M,20/01/1934,73,61-75 years                            

Lera,XXXXX,IDXXXX,F,11/07/1986,21,15-30 years                               

Wilma,XXXXX,IDXXXX,F,23/06/1984,23,15-30 years                            

Patrick,XXXXX,IDXXXX,M,14/04/1939,68,61-75 years                            

Portia,XXXXX,IDXXXX,F,11/02/1964,43,31-45 years                           

Soberina,XXXXX,IDXXXX,F,27/09/1986,21,15-30 years                          

Angel,XXXXX,IDXXXX,F,19/12/1969,38,31-45 years                            

Alex,XXXXX,IDXXXX,M,22/04/1986,21,15-30 years                          

Kenan,XXXXX,IDXXXX,M,10/02/1964,43,31-45 years    

                       


Accepted Solutions
Solution
‎07-01-2015 02:43 PM
Valued Guide
Posts: 860

Re: Informat date not processing correctly

Posted in reply to orangerunner10

Informat is how the data will be read IN, format is how the data will be displayed.  You should use both.

informat birthdate ddmmyy10.;

format birthdate ddmmyy10.;

View solution in original post


All Replies
Solution
‎07-01-2015 02:43 PM
Valued Guide
Posts: 860

Re: Informat date not processing correctly

Posted in reply to orangerunner10

Informat is how the data will be read IN, format is how the data will be displayed.  You should use both.

informat birthdate ddmmyy10.;

format birthdate ddmmyy10.;

Occasional Contributor
Posts: 5

Re: Informat date not processing correctly

Posted in reply to Steelers_In_DC

Hey Marc!

Alright, so I tried that and it now recognizes the dates correctly!!

Thank you so much!!!

Valued Guide
Posts: 860

Re: Informat date not processing correctly

Posted in reply to orangerunner10

Change the informat and format for whatever situation applies.

informat birthdate ddmmyy10.;

format dtmonyy7.;

should do the trick.

Mark

Occasional Contributor
Posts: 5

Re: Informat date not processing correctly

Posted in reply to Steelers_In_DC

Thank you all!!

Valued Guide
Posts: 2,177

Re: Informat date not processing correctly

Posted in reply to orangerunner10

Remove that DT from dtmonyy

It is suitable when the value is a timestamp but you have a date

🔒 This topic is solved and locked.

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

Discussion stats
  • 5 replies
  • 326 views
  • 0 likes
  • 3 in conversation