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

Hi SAS Communities,

 

The original data of Bithmonth and Birthday does not have a leading zero, so if I code in the following way, when I put FORMAT BirthDt MMDDYY10.; some of the data will show up ****. Do you mind telling me how I can add leading zero in my code, please?

 

 

Here is my code:

 

	BirthDt = 	CATS(BirthYear, BirthMonth, BirthDay);
	

Question.jpg

 

 

Thanks,

Valerie

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

CATS is a character function, but SAS dates are numeric. SAS dates are a count of days with 1960-01-01 as day zero.

To create a date from separate year/month/day values, you use the MDY function:

BirthDt = mdy(BirthMonth,BirthDay,BirthYear);

Then the format will work (for reasonable values of year).

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

CATS is a character function, but SAS dates are numeric. SAS dates are a count of days with 1960-01-01 as day zero.

To create a date from separate year/month/day values, you use the MDY function:

BirthDt = mdy(BirthMonth,BirthDay,BirthYear);

Then the format will work (for reasonable values of year).

PeterClemmensen
Tourmaline | Level 20

Dates are numeric and CATS is applied to character values..

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 3424 views
  • 1 like
  • 3 in conversation