BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
walkerel
Calcite | Level 5
DATA Hypanl.Hypanalysis2;
	merge WORK.RecentVisit (IN = InRecentVisit)
		  HypTabs.contact (IN= Incontact)
		  HypTabs.demog (IN = Indemog)
		  HypTabs.ndi ( IN= Inndi);
	BY SSN;
	IF InRecentVisit = 1 AND Incontact = 1 AND Indemog = 1 AND Inndi = 1;
    AgeAtVisit = YRDIF(BirthDt, VisitDt, 'AGE');
	FORMAT AgeAtVisit 4.1;
RUN;

I am currently working to merge the first three data sets and exclude those that are in the ndi data set. My problem is when I try to create the AgeAtVisit variable. I keep getting the note below and a missing value for the AgeAtVisit variable. (This is not real data. It was created for the purposes of teaching concepts and skills).

 

NOTE: Invalid argument to function YRDIF(.,19450,'AGE') at line 80 column 15.
InRecentVisit=1 Incontact=1 Indemog=1 Inndi=1 SSN=XXX-XX-XXXX VisitDt=02APR2013 HtIn=67 WtLb=159 SBP=159 DBP=65 Inits=TRB City=Provo
StateCd=Utah ZipCd=84604 GenderCd=Male EthCd=Non-Hispanic RaceCd=White EthRaceCd=NH White BirthDt=. DeathDt=2015-05-26 ICD10=I25.21
CODCd=Heart Disease HypRelDeathInd=Yes FIRST.SSN=1 LAST.SSN=1 AgeAtVisit=. _ERROR_=1 _N_=629
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

As Reeza pointed out, Add a condition to fix it.

 

 if not missing (BirthDt)  and not missing(VisitDt) then AgeAtVisit = YRDIF(BirthDt, VisitDt, 'AGE');

View solution in original post

2 REPLIES 2
Reeza
Super User

Look at the log and if this is real data let me know please be more careful with your posts, you've included enough to identify a person, including SSN, location (Utah), gender and zip code. I've masked the SSN and removed it from your original post.

 

For the record here, birth date is missing so you cannot calculate an age. 

 

NOTE: Invalid argument to function YRDIF(.,19450,'AGE') at line 80 column 15.
InRecentVisit=1 Incontact=1 Indemog=1 Inndi=1 SSN=XXXXXXX VisitDt=02APR2013 HtIn=67 WtLb=159 SBP=159 DBP=65 Inits=TRB City=Provo
StateCd=Utah ZipCd=84604 GenderCd=Male EthCd=Non-Hispanic RaceCd=White EthRaceCd=NH White BirthDt=. DeathDt=2015-05-26 ICD10=I25.21
CODCd=Heart Disease HypRelDeathInd=Yes FIRST.SSN=1 LAST.SSN=1 AgeAtVisit=. _ERROR_=1 _N_=629
Ksharp
Super User

As Reeza pointed out, Add a condition to fix it.

 

 if not missing (BirthDt)  and not missing(VisitDt) then AgeAtVisit = YRDIF(BirthDt, VisitDt, 'AGE');

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 449 views
  • 2 likes
  • 3 in conversation