BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ahmad
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

2 REPLIES 2
Tom
Super User Tom
Super User

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;

Ahmad
Calcite | Level 5

thanks tom it was silly of me

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

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