BookmarkSubscribeRSS Feed
sas1018
Fluorite | Level 6

hi

I have a birth variable in a dataset which is character type. Now I want to convert into is8601da. format. First I created another variable to change the birth variable to numeric and then use the put function to apply the format. I have tried the below code:

 

birth1=input(birth,anydtdtm20.);
BRTHDTC=put(birth1,is8601da.);

 

birth variable format in the dataset ::::1988-08-29

I got  ********** this for BRTHDTC. What am I doing wrong? Can anybody help me with this.

 

TIA.

2 REPLIES 2
PaigeMiller
Diamond | Level 26
data have;
    birth='1988-08-29';
	birth_numeric=input(birth,anydtdte.);
	format birth_numeric is8601da.;
run;

You can't use informat anydtdtm. because that expects date/time values, and you have only a date value, so you need informat anydtdte. 

--
Paige Miller
ballardw
Super User

Here is a useful reference regarding dates, times and datetimes in SAS.

 

https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.

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

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