Desktop productivity for business analysts and programmers

Date DDMMMYYYY

Reply
Contributor
Posts: 73

Date DDMMMYYYY

Hello EG Users,

I am running into very standard issue of converting variables that represent into format that my code likes. In this snippet, I intend to create just one observation in TemporaryDays dataset that represents February 3 2014, however I need it to be in this format 03FEB2014

data work.TemporaryDays;

input MDay $ 1-9;

MDay = input(MDay, DDMMMYY9.);

datalines;

03FEB2014

;

run;

quit;

Error:

NOTE 485-185: Informat DDMMMYY was not found or could not be loaded.

How do I go about making changes so that observation stored in TemporaryDays is of type date and not character; that matches what it would look like if I were doing:

MDay = '03FEB2014'd;

Thank you very much!

Dhanashree

Grand Advisor
Posts: 10,210

Re: Date DDMMMYYYY

Since MDAY was declared character using: Input Mday $ 1-9; then attempting to re-create it as a date-valued numeric in the second line would fail. Either assign an informat before reading or create a new variable. The appropriate informat for data in your example is DATEw.

data ;

     informat Mday date9.;

     input Mday 1-9;

     format Mday mmddyy10.;

run;

Contributor
Posts: 73

Re: Date DDMMMYYYY

WEll , in that case why do I need

format MDay mmddyy10.;

Shouldn't that be same as DATE9.?

In any case, I tried it out and running into no errors but the dataset has observation with missing value in it

NOTE: Invalid data for MDay in line 20 1-9.
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8---
20         03FEB2014

MDay=. _ERROR_=1 _N_=1

Thanks for your suggestions!

Contributor
Posts: 73

Re: Date DDMMMYYYY

Its ok, I see what you are saying now...

Thanks again ballardw Smiley Happy

Ask a Question
Discussion stats
  • 3 replies
  • 489 views
  • 3 likes
  • 2 in conversation