Need to convert anydttm40. to monname3.

Reply
Occasional Contributor
Posts: 11

Need to convert anydttm40. to monname3.

After a proc import I would like to format the date to monname3. format, when I do this it either returns a blank or the correct date format and moves the data in the columns over to the right.

Super User
Posts: 19,157

Re: Need to convert anydttm40. to monname3.

You have a datetime variable, so you need a datetime format. I'm not sure, but you can try dtmonname3. OR you cna create a new variable using the datepart function and apply the monname3 format to it.

new_var=datepart(old_var);

format new_var monname3.;

Occasional Contributor
Posts: 11

Re: Need to convert anydttm40. to monname3.

Thank you Reeza, I tried both ways, it is just keeping the original informat date.  I will keep playing with it.

Super User
Posts: 19,157

Re: Need to convert anydttm40. to monname3.

You say informat instead of format this time, they are two different things. Can you clarify your issue some more? Ideally, a proc contents before, the code you tried and proc contents after.

Occasional Contributor
Posts: 11

Re: Need to convert anydttm40. to monname3.

Hi Reeza, my apologies for the confusion.  I did a proc import and the back code generated an informat anydttm40. that I hoped to modify to the monname3. format.  Whether I try to modify this in a subsequent data step or just redo the import as a data step/infile, I can't seem to get the date to read in the format I need.  If it does, it pushes all the data in my columns one column to the right and sets several data values in the misaligned columns to missing.

Super User
Posts: 11,134

Re: Need to convert anydttm40. to monname3.

One of my pet peeves is the tendency for many programs treat all dates as datetime variables. They are not the same. One of the reasons I don't use proc import in general is I can read files and specify an informat that only reads the date part of these erroneously constructed dates.

Ask a Question
Discussion stats
  • 5 replies
  • 233 views
  • 1 like
  • 3 in conversation