SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tejaswini3
Obsidian | Level 7

Kindly see the below code

 

data PKMERGE;
set PKDAR;
/*Derivation of age*/
age=intck('year',VSN1D, DOB1D, 'Continuous'); /*Check the age*/
run;

The below log appears

NOTE: Invalid numeric data, ATLSMP1T='10:58' , at line 117
      column 15.
NOTE: Invalid numeric data, SMP1D='20MAR2006' , at line 117
      column 30

The image of data


 
Updating Media

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

The NOTEs about conversion from character to numeric indicate that you do not have date values (numeric, count of days starting at 1960-01-01), but strings that look like dates. You need to correct that when the dataset(s) that lead up to this are created.

View solution in original post

6 REPLIES 6
Kurt_Bremser
Super User

The code you posted does not use any of the variables mentioned in the messages.

Please post the complete log of the actual step that caused the NOTEs you posted.

Tejaswini3
Obsidian | Level 7

Kindly see the log below in image.. Not able to type as text.

 

Tejaswini3_0-1646493164101.png

 

PaigeMiller
Diamond | Level 26

As the log clearly points out

 

ATLSMP1T='10:58'

in not a valid numeric value. Do you understand why?

 

However if you put a letter T after it, then it becomes a valid SAS time value.

 

ATLSMP1T='10:58't

However, looking at your code, you need to fix this in data set PKDAR, as we don't know how that was created.

 

In the future, please present your LOG as text and not as a screen capture. In the future, please include the text of your LOG in the window that appears when you click on the </> icon

2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png

--
Paige Miller
Kurt_Bremser
Super User

The NOTEs about conversion from character to numeric indicate that you do not have date values (numeric, count of days starting at 1960-01-01), but strings that look like dates. You need to correct that when the dataset(s) that lead up to this are created.

Tejaswini3
Obsidian | Level 7

Following log is seen

NOTE: Character values have been converted to numeric
      values at the places given by: (Line):(Column).
      266:18   266:25
NOTE: Invalid numeric data, VSN1D='18APR2006' , at line 266
      column 18.
NOTE: Invalid numeric data, DOB1D='08JUL1955' , at line 266
      column 25.

Kindly help in how to resolve

Sajid01
Meteorite | Level 14

Hello @Tejaswini3 
Looks like the format of the date variables DOBID and VSNID are not properly defined.
This can be clearly seen from the screen shot of the log you have posted. Once this is corrected, you should be able to calculate the age. Have a look at the example below and it should help.
Initially the variables DOB and VSD are character type. They are converted to date format and used.

data test (keep =name DOBID VSNID age);
length name $ 20 DOB VSD $9;
format DOBID VSNID date9.;
input name $ DOB $ VSD;
DOBID=input(DOB,date9.);
VSNID=input(VSD,date9.);
age=intck('year',DOBID, VSNID, 'Continuous');
dataline;
SOME_NAME 18JUL1955 18APR2006
;
run;

The output would be as follows

Sajid01_0-1646508476608.png

Make appropriate changes to suit your situation.

 Your question was on age calculation. I have focused on that. Other errors if any need to be appropriately addressed.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1845 views
  • 2 likes
  • 4 in conversation