A change to your thought processes is not a solution.
Please be kind enough to help us understand and clearly state the solution to your programming issue.
I still bet it was improper reading of text file.
Example:
data have;
input
@1 dob :mmddyy. date :mmddyy.
@1 bad_dob mmddyy10. bad_date mmddyy10.
;
format _all_ date9.;
cards;
1/1/1960 4/28/1987
1/1/1960 9/28/2021
1/10/1960 12/18/2012
1/9/1960 6/5/2007
12/31/1959 1/11/2024
;
Results
Obs dob date bad_dob bad_date 1 01JAN1960 28APR1987 01JAN1960 . 2 01JAN1960 28SEP2021 01JAN1960 . 3 10JAN1960 18DEC2012 10JAN1960 18DEC2012 4 09JAN1960 05JUN2007 09JAN1960 . 5 31DEC1959 11JAN2024 31DEC1959 11JAN2024
Log
1 data have; 2 input 3 @1 dob :mmddyy. date :mmddyy. 4 @1 bad_dob mmddyy10. bad_date mmddyy10. 5 ; 6 format _all_ date9.; 7 cards; NOTE: Invalid data for bad_date in line 8 11-20. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+---- 8 1/1/1960 4/28/1987 dob=01JAN1960 date=28APR1987 bad_dob=01JAN1960 bad_date=. _ERROR_=1 _N_=1 NOTE: Invalid data for bad_date in line 9 11-20. 9 1/1/1960 9/28/2021 dob=01JAN1960 date=28SEP2021 bad_dob=01JAN1960 bad_date=. _ERROR_=1 _N_=2 NOTE: Invalid data for bad_date in line 11 11-20. 11 1/9/1960 6/5/2007 dob=09JAN1960 date=05JUN2007 bad_dob=09JAN1960 bad_date=. _ERROR_=1 _N_=4 NOTE: The data set WORK.HAVE has 5 observations and 4 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
Sorry, I'm not good enough to clearly state the problem and/or solution. That data step performed other functions and when I moved the age determination outside of the problematic data step it worked just fine and that's the most important thing. The data step performed other functions so I'm assuming one conflicted or one of the variables in my function was dependent on that and I was attempting to this age calculation. Moving it outside of the data step eliminated that conflict and it runs just fine. The key concept from Cynthia and Paige was that perhaps my function wasn't to blame (since I did not change it, I just moved it). So it wasn't the particular function at fault, which is what I had focused on. A good reminder to me to check other possibilities.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.