BookmarkSubscribeRSS Feed
qinghe
Calcite | Level 5

Hi,

 

I have got the following information in the log:

NOTE: Invalid argument to function YRDIF at line 21 column 18.

NOTE: Invalid second argument to function SUBSTR at line 26 column 9.

NOTE: Invalid second argument to function SUBSTR at line 27 column 9.

The lines 21 to 27 ar as below:

21 age_at_131015 = yrdif(birth_date, '13oct2015'd, 'act/act');

22 if age_at_131015 <5 then age_grp="0-4";

23 else if age_at_131015 <15 then age_grp="5-14";

24 else age_group="15+";

25 if substr(Indigenous_status, 1, 1)="A" or substr(Indigenous_status, 1, 1)="T" then Indig=1;

26 else if substr(compress(Indigenous_status), 1, 4)="NOTA" then Indig=2;

27 else if substr(compress(Indigenous_status), 1, 4)="NOTS" then Indig=9;

 

What I did wrong?

 

Thanks.

 

qinghe

2 REPLIES 2
Reeza
Super User

Most likely you forgot to account for missing values. 

Birth_date is probably missing, and indigineous status is less than 4 characters, or missing, so trying to take a substring of length 4 isn't possible.

 

If you look closer at your log, it will show sample data points and you can verify the value of birth_date and/or indigineous status to verify my guess.

qinghe
Calcite | Level 5

Thanks, Reeza

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 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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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