BookmarkSubscribeRSS Feed
jonatan_velarde
Lapis Lazuli | Level 10

Good morning:

 

I have an dataset and i have to replace some dates (including formats):

 

i was trying to use this:

 

data have;

input   ID        birth_day:mmddyy10.;

format     birth_day mmddyy10.;

cards;

1515         03/22/2000

1533         12/19/2000

;

 

Data want;

set have;

if ID = 1515 then birth_day = '01/26/2003';

if ID = 1533 then birth_day = '01/30/2004';

run;

 

I tried this estatements and it is not working

 

Can anybody give me some hints please??

 

 

thanks

3 REPLIES 3
LinusH
Tourmaline | Level 20

The date your are trying to assign is a string, dates in SAS a numerical.

If you wish to express a data constant, you need to use the date format and using a data literal:

 

'01Jan205'd

Data never sleeps
jonatan_velarde
Lapis Lazuli | Level 10

Thanks for your answer:

 

i use this format:

 

mmddyy10.

 

the original data is formated like this.

 

ill try and give notices

ballardw
Super User

The value of a Date literal must be in the form of 'ddMONyy'd or 'ddMONyyyy'd for SAS to recognize it as a date. If you have assigned a format of mmddyy10. to the variable then that is the default appearance the value will have in your data set.

 

 

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
  • 3 replies
  • 1268 views
  • 0 likes
  • 3 in conversation