DATA Step, Macro, Functions and more

invalid argument

Reply
Occasional Contributor
Posts: 5

invalid argument

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.

Trusted Advisor
Posts: 1,610

Re: invalid argument

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

Super User
Super User
Posts: 7,392

Re: invalid argument

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.  

Occasional Contributor
Posts: 5

Re: invalid argument

it is date variable stored as numaric 

Super User
Super User
Posts: 7,392

Re: invalid argument

So you want, in this context:

 

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

 

Occasional Contributor
Posts: 5

Re: invalid argument

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.

Super User
Super User
Posts: 7,392

Re: invalid argument

Its just a typo, I put one extra f:

if taper_d ne . then taper_a=yrdif(dob,taper_d,"actual"); 
Occasional Contributor
Posts: 5

Re: invalid argument


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 . 

Super User
Super User
Posts: 7,392

Re: invalid argument

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.

Occasional Contributor
Posts: 5

Re: invalid argument

The data stored the numaric missing as blank 

Super User
Posts: 5,080

Re: invalid argument

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.

Ask a Question
Discussion stats
  • 10 replies
  • 123 views
  • 0 likes
  • 4 in conversation