So sorry for not providing complete information and thank you for responding. The solution that you have provided works for the test dataset that was created for this question. However, I am getting the following error in my original dataset. ERROR 48-59: The format $YYMMDD was not found or could not be loaded. Please see the log below that has the similar kind of code. 264 data labcd4age /*labcd4anly labcd4_agelt13*/; 265 set lab_cd4anly1; 266 birth_dt=input(dob,yymmdd8.); 267 collectdt=input(sample_dt, yymmdd8.); 268 format birth_dt collectdt yymmdd8.; 269 age=yrdif(birth_dt, collectdt); 270 format dob collectdt yymmdd8.; -------- 48 ERROR 48-59: The format $YYMMDD was not found or could not be loaded. 271 /*if age>=13 then output labcd4anly; else 272 output labcd4_agelt13;*/ 273 run; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.LABCD4AGE may be incomplete. When this step was stopped there were 0 observations and 15 variables. WARNING: Data set WORK.LABCD4AGE was not replaced because this step was stopped. Please note these are the variable properties in the original dataset Alphabetic List of Variables and Attributes # Variable Type Len Format Informat Label 10 dob Char 8 $8. $8. dob 3 sample_dt Char 8 $8. $8. sample_dt
... View more