BookmarkSubscribeRSS Feed
noobs
Fluorite | Level 6

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

3 REPLIES 3
ballardw
Super User

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;

noobs
Fluorite | Level 6

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!

noobs
Fluorite | Level 6

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

Thanks again ballardw Smiley Happy

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 4810 views
  • 3 likes
  • 2 in conversation