BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cbrotz
Pyrite | Level 9

I am looking to remove the slashes from a date field.  The following format with the "n" returns an error. Any ideas appreciated.

 

 

Original data is a date field called month in this format:

 

20161201
20160801
20161201
20161201
20161001
20161101
20161101

 

 

data fix_date;
set work.query_for_objectives_for_reports;
month = intnx('month',month1,0,"BEGINNING");
format month mmddyyn10.;

run;

 

%LET _CLIENTPROJECTPATHHOST='';
7 %LET _CLIENTPROJECTNAME='';
8 %LET _SASPROGRAMFILE='';
9 %LET _SASPROGRAMFILEHOST='';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=PNG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14
15 GOPTIONS ACCESSIBLE;
16 data fix_date;
17 set work.query_for_objectives_for_reports;
18 month = intnx('month',month1,0,"BEGINNING");
19 format month mmddyyn10.;
__________
29
ERROR 29-185: Width specified for format MMDDYYN is invalid.

20
21 run;

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19
use width 8. mmddyyn8,;

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

What error? Show us the SAS log, not just the ERROR message, but the entire DATA step with subsequent ERROR message and notes. Please paste the log into the window that appears when you click on the {i} icon.

--
Paige Miller
cbrotz
Pyrite | Level 9

Added log....

data_null__
Jade | Level 19
use width 8. mmddyyn8,;
cbrotz
Pyrite | Level 9

Thank you!

 

ballardw
Super User

From the documentation of the mmddyxw. format:

 

Interactions When w has a value of from 2 to 5, the date appears with as much of the month and the day as possible. When w is 7, the date appears as a two-digit year without separators.
When x has a value of N, the width range changes to 2–8.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 2920 views
  • 0 likes
  • 4 in conversation