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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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