BookmarkSubscribeRSS Feed
raveena
Obsidian | Level 7
Hi,

I need to convert the date part (effdate field) from MMDDYYYY to CCYYMMDD.

The current sample data \
ID Name Effdat
001 David 05/01/2003
002 bob 04/01/1997
003 ben 08/09/2011

I tried like this,

Proc sql;
Create table test as
Select ID, name, INPUT (effdat, CCYYMMDD.) format=CCYYMMDD. From table1;
QUIT;

I am getting an error.

Can anyone please help me to resolve this issue.

Thanks in Adavance.
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Need to know the exact error - which determines what type of SAS variable (CHAR or NUMERIC) is being referenced when attempting the INPUT function with effdat (or effdate - whatever).

Also, for clarification about "CC", please provide an example of what you expect the value to be for a given calendar year?

There are various SAS formats (using PUT, not INPUT, depending on the source variable format CHAR or NUMERIC) that may convert your DATE variable properly.

Scott Barry
SBBWorks, Inc.
ballardw
Super User
I suspect the errors you are getting are format doesn't exist.

Is EFFDAT numeric and currently displayed with a MMDDYY10. format or is it actually text? The resolution is very dependent on the answer.

The final format you want is probably YYMMDDN8. if you do not want any delimiter in the final display, instead of CCYYMMDD. SAS date display formats doe not use a century component per se.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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