BookmarkSubscribeRSS Feed
noobs
Calcite | Level 5

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
Calcite | Level 5

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
Calcite | Level 5

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

Thanks again ballardw Smiley Happy

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 4024 views
  • 3 likes
  • 2 in conversation