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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1622 views
  • 0 likes
  • 3 in conversation