BookmarkSubscribeRSS Feed
Patelbb
Fluorite | Level 6

Hi,

 

I keep getting an error that states invalid numeric data error. Here is my code:

 

data demo;
   set dbraw.x_dm;
   **Create four new variables**;
   length RPTDT AGERPT AGETHEN 8 SUBJID $20;
   label RPTDT   = "Study Report Date"
         AGERPT  = "Age of Subject aat Time of Report (Yrs)"
         AGETHEN = "Age of Subject at Time of Study (Yrs)"
         SUBJID  = "Subject ID/Age"
;
   RPTDT = mdy (6,28,13);
   format RPTDT mmddyy10.;
   AGERPT = INT((RPTDT - S_BRTHDTC + 1)/365.25);
   AGETHEN = INT((S_ICFDTC - S_BRTHDTC + 1)/365.25);
   SUBJID = catx('-',s_siteid,s_subjid,AGERPT);
run;
 
Here is part of the log:
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      323:26   324:19   324:30
NOTE: Invalid numeric data, S_BRTHDTC='11AUG1946' , at line 323 column 26.
NOTE: Invalid numeric data, S_ICFDTC='14JAN2013' , at line 324 column 19.
NOTE: Invalid numeric data, S_BRTHDTC='11AUG1946' , at line 324 column 30.
STUDYID=ABC-123 S_DOMAIN=X_DM S_SITEID=1160 S_SUBJID=2576 S_INIT=S-B COUNTRY=USA REGION=USA S_PAGE=1 S_VISDTC=14JAN2013
S_VISIT=SCREENING S_VISITNUM=-1 S_ICFDTC=14JAN2013 S_BRTHDTC=11AUG1946 S_AGE=66 S_SEX=M S_ETHNIC=NOT HISPANIC OR LATINO S_RACE1=
S_RACE2=  S_RACE3=  S_RACE4=  S_RACE5=CHECKED S_RACE6=  S_RACEOTH=  ROW_NO=0 S_STATUS=CDQC REVIEWED S_SDV_STAT=FULL FORM SDV
RPTDT=06/28/2013 AGERPT=. AGETHEN=. SUBJID=1160-2576-. _ERROR_=1 _N_=1
3 REPLIES 3
Kurt_Bremser
Super User

"11AUG1946" is a string used in SAS date literals, but then it needs to be written as "11AUG1946"d. (note the d immediately after the closing quote)

The string itself is just that, a string, and can't be used where a number is required.

Patelbb
Fluorite | Level 6

Hi,

 

Thank you for you response. I'm new to SAS so I'm not sure how to fix it. Can you help please?

Kurt_Bremser
Super User

Start by determining how you get those strings in your data in the first place. I'm 99% sure those should have been valid SAS dates and not character variables.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1498 views
  • 0 likes
  • 2 in conversation