BookmarkSubscribeRSS Feed
mona4u
Lapis Lazuli | Level 10

when I use this function it give error message me invalid agrgument 

 

TAPER_A=YRDIF(DOB,datepart(TAPER_D),"ACTUAL");

 

 

NOTE: Invalid argument to function YRDIF(13371,.,'ACTUAL') at line 770 column 11.

10 REPLIES 10
PaigeMiller
Diamond | Level 26

It would appear that the value of datepart(TAPER_D) is missing, and that is not allowed.

--
Paige Miller
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Are you sure that taper_d is a datetime variable and not just a date variable?  This is one reason why we always ask for test data in the form of a datastep, if we can see the data and the structure, then we can imediately say wether it is that or not, now we have to have this back and forth, is the variable numeric, is it a date varaible, does it have non-missing data etc.  

mona4u
Lapis Lazuli | Level 10

it is date variable stored as numaric 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

So you want, in this context:

 

if taper_d ne . then taper_a=yrdiff(dob,taper_d,"actual"); 

 

mona4u
Lapis Lazuli | Level 10

11549 if TAPER_D ne . then TAPER_A=yrdiff(DOB,TAPER_D,"actual");
------
68
ERROR 68-185: The function YRDIFF is unknown, or cannot be accessed.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Its just a typo, I put one extra f:

if taper_d ne . then taper_a=yrdif(dob,taper_d,"actual"); 
mona4u
Lapis Lazuli | Level 10


NOTE: Invalid argument to function YRDIF( ,18148,'ACTUAL') at line 12375 column 34.
NOTE: Invalid argument to function YRDIF( ,18189,'actual') at line 12378 column 30. 

 

also I find the data stored the numaric missing as blnk not as . 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Please post test data in the form of a datastep!!

 

 

We have now gone back and forward several times purely because I can't see the data.  It now seems your saying that DOB is a character variable not numeric.  If so then you need to convert it to numeric, and also add into the logic if <date1> is not missing and <date2> is not missing.

mona4u
Lapis Lazuli | Level 10

The data stored the numaric missing as blank 

Astounding
PROC Star

This would be a normal result if the variable TAPER_D occasionally takes on a missing value.  For those observations, there's no way to compute TAPER_A.

 

It's not clear whether using DATEPART is the correct step or not, but it is not causing missing values for TAPER_A.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 10 replies
  • 1330 views
  • 0 likes
  • 4 in conversation