Help using Base SAS procedures

converting date part

Reply
Frequent Contributor
Posts: 90

converting date part

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.
Super Contributor
Super Contributor
Posts: 3,174

Re: converting date part

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.
Super User
Posts: 10,458

Re: converting date part

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.
Ask a Question
Discussion stats
  • 2 replies
  • 887 views
  • 0 likes
  • 3 in conversation