DATA Step, Macro, Functions and more

Converting EURDFDD10. to DATE9. using Enterprise Guide

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

Converting EURDFDD10. to DATE9. using Enterprise Guide

Hello!

I have a .csv file that is an extract from SAP.  The all dates have the following format: dd.mm.yyyy.  I would like to properly convert this to DATE9. format using EG.  Any suggestions?

-Joshua


Accepted Solutions
Solution
‎05-07-2015 11:19 AM
Super User
Posts: 11,343

Re: Converting EURDFDD10. to DATE9. using Enterprise Guide

Posted in reply to J_squared

Read the variable(s) using the ddmmyy format and assign the date9. format.

And you aren't "converting" but creating a SAS date valued variable. Then you can display and manipulate the variables with many formats or date functions.

data test;
informat date ddmmyy10.;
input date;
format date date9.;

datalines;
15.04.2012
;
run;

View solution in original post


All Replies
Solution
‎05-07-2015 11:19 AM
Super User
Posts: 11,343

Re: Converting EURDFDD10. to DATE9. using Enterprise Guide

Posted in reply to J_squared

Read the variable(s) using the ddmmyy format and assign the date9. format.

And you aren't "converting" but creating a SAS date valued variable. Then you can display and manipulate the variables with many formats or date functions.

data test;
informat date ddmmyy10.;
input date;
format date date9.;

datalines;
15.04.2012
;
run;

Community Manager
Posts: 2,955

Re: Converting EURDFDD10. to DATE9. using Enterprise Guide

And if you're using the Import Data task to accomplish this, you can Modify the input Source Informat on the Field Attributes screen.  Select the column, click Modify, then specify the DDMMYY10. informat:

fmt.png

Occasional Contributor
Posts: 10

Re: Converting EURDFDD10. to DATE9. using Enterprise Guide

Posted in reply to ChrisHemedinger

Thanks, Chris!  I also used your suggestion regarding the ANYDTDTE informat... I changed the default field attribute for this variable from Type: String to Type: Date and then changed the Input format from DATE9. to ANYDTDTE10. as well... The output looks correct!

EURDFDD10.png

Community Manager
Posts: 2,955

Re: Converting EURDFDD10. to DATE9. using Enterprise Guide

Posted in reply to J_squared

Great! Just keep in mind that the OPTIONS DATESTYLE= value will influence how the "ambiguous" dates turn out when using the ANYDT* collection of SAS informats.

options datestyle=mdy; /* 01.12.2015 will come in as 12JAN2015 */

options datestyle=dmy; /* 01.12.2015 will come in as 01DEC2015 */


You can add the proper option as a SAS program node ahead of the Import Data step to control this.  You might also want to set it back to the default (DATESTYLE=LOCALE) when done.

Occasional Contributor
Posts: 10

Re: Converting EURDFDD10. to DATE9. using Enterprise Guide

Posted in reply to ChrisHemedinger

Like this...

datestyle_path.png

The datestyle program contains the following...

program.png

Community Manager
Posts: 2,955

Re: Converting EURDFDD10. to DATE9. using Enterprise Guide

Posted in reply to J_squared

You got it!  Such a fast learner.

Don't tell the others, but you were one of my best students in our class.  I don't like to play favorites, but you were definitely in the top 6.

Occasional Contributor
Posts: 10

Re: Converting EURDFDD10. to DATE9. using Enterprise Guide

Posted in reply to ChrisHemedinger

LOL a pupil is only as good has his/her instructor! Smiley Happy

Occasional Contributor
Posts: 10

Re: Converting EURDFDD10. to DATE9. using Enterprise Guide

Thank you very much!  That worked nicely!

🔒 This topic is solved and locked.

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

Discussion stats
  • 8 replies
  • 469 views
  • 2 likes
  • 3 in conversation