Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Error when creatin a yymm8. variable from date

Accepted Solution Solved
Reply
Contributor
Posts: 43
Accepted Solution

Error when creatin a yymm8. variable from date

hi i am trying to create a year-month (e.g  2006-01) variable from my daily date variable using the command MONTH=put(date,yymmd8.),

however it is giving me the error

     877:9

NOTE: Invalid numeric data, ' 2006-01' , at line 877 column 9.

DATE=16803 alhspr=. spread=. year=2006 month=. _ERROR_=1 _N_=2

NOTE: Invalid numeric data, ' 2006-01' , at line 877 column 9

I have used this method earlier but i dont know y sas is constantly giving me this  error now.

Any help would be highly appreciated

Thanks


Accepted Solutions
Solution
‎03-28-2013 09:11 PM
Super User
Super User
Posts: 6,502

Re: Error when creatin a yymm8. variable from date

You have previously defined MONTH as a numeric variable. So SAS cannot figure out how to convert '2006-01' into a number to stick into your numeric variable.  The code below illustrates the problem.

data _null_;

  length num 8 char $7 ;

  char = put('01JAN2006'd,yymmd7.);

  num = put('01JAN2006'd,yymmd7.);

run;

View solution in original post


All Replies
Solution
‎03-28-2013 09:11 PM
Super User
Super User
Posts: 6,502

Re: Error when creatin a yymm8. variable from date

You have previously defined MONTH as a numeric variable. So SAS cannot figure out how to convert '2006-01' into a number to stick into your numeric variable.  The code below illustrates the problem.

data _null_;

  length num 8 char $7 ;

  char = put('01JAN2006'd,yymmd7.);

  num = put('01JAN2006'd,yymmd7.);

run;

Contributor
Posts: 43

Re: Error when creatin a yymm8. variable from date

thanks tom it was silly of me

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 310 views
  • 0 likes
  • 2 in conversation