DATA Step, Macro, Functions and more

need help

Accepted Solution Solved
Reply
Contributor sss
Contributor
Posts: 65
Accepted Solution

need help

I am having a variable by name DT_DUNNING_DATE which is off type numeric with BEST12. format

I am tring to apply format ie date9. on this column but i am getting an error msg.

DATA TEMP;

SET DUNNING;

DT_DUNNING_DATE1=INPUT(DT_DUNNING_DATE,DATE9.);

FORMAT DT_DUNNING_DATE1 DATE9.;

RUN;

ERROR:there was a problem with format so best. is used.

variable values in table as follow

DT_DUNNING_DATE

19980428

20100324

20110330

PLS HELP ME OUT


Accepted Solutions
Solution
‎12-16-2011 10:04 AM
PROC Star
Posts: 7,471

Re: need help

I think that you are looking for something like:

data dunning;

  input DT_DUNNING_DATE;

  cards;

19980428

20100324

20110330

;

DATA TEMP;

  SET DUNNING;

  DT_DUNNING_DATE1=

   INPUT(put(DT_DUNNING_DATE,8.),yymmdd8.);

  FORMAT DT_DUNNING_DATE1 DATE9.;

RUN;

View solution in original post


All Replies
Solution
‎12-16-2011 10:04 AM
PROC Star
Posts: 7,471

Re: need help

I think that you are looking for something like:

data dunning;

  input DT_DUNNING_DATE;

  cards;

19980428

20100324

20110330

;

DATA TEMP;

  SET DUNNING;

  DT_DUNNING_DATE1=

   INPUT(put(DT_DUNNING_DATE,8.),yymmdd8.);

  FORMAT DT_DUNNING_DATE1 DATE9.;

RUN;

Super User
Posts: 11,343

Re: need help

Shorter:

data dunning; 

input DT_DUNNING_DATE :yymmdd8.; 

format DT_DUNNING_DATE date9.;  

cards;

19980428

20100324

20110330 ;

run;

Contributor
Posts: 35

need help

@art297 is completely correct. As the input values in the dataset is in YYYYMMDD format you have to first read them in yymmdd8. format then you can change them to Date9. format easily.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 127 views
  • 0 likes
  • 4 in conversation