BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
orangerunner10
Calcite | Level 5

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    

                       

1 ACCEPTED SOLUTION

Accepted Solutions
Steelers_In_DC
Barite | Level 11

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

5 REPLIES 5
Steelers_In_DC
Barite | Level 11

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.;

orangerunner10
Calcite | Level 5

Hey Marc!

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

Thank you so much!!!

Steelers_In_DC
Barite | Level 11

Change the informat and format for whatever situation applies.

informat birthdate ddmmyy10.;

format dtmonyy7.;

should do the trick.

Mark

orangerunner10
Calcite | Level 5

Thank you all!!

Peter_C
Rhodochrosite | Level 12

Remove that DT from dtmonyy

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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