DATA Logins;
SET SASUSER.NTBPLRC;
DOB_TEMP = TRANWRD(DOB, "0:0:0. 0", "");
DOB = MDY(SCAN(DOB_TEMP,2,"-"), SCAN(DOB_TEMP,3,"-"), SCAN(DOB_TEMP, 1,"-"));
FORMAT DOB DATE9.;
RUN;
I am getting the following error:
DATA Logins;
16 SET SASUSER.NTBPLRC;
17 DOB_TEMP = TRANWRD(DOB, "0:0:0. 0", "");
18 DOB = MDY(SCAN(DOB_TEMP,2,"-"), SCAN(DOB_TEMP,3,"-"), SCAN(DOB_TEMP, 1,"-"));
19 FORMAT DOB DATE9.;
______
484
NOTE 484-185: Format $DATE was not found or could not be loaded.
Please help to solve the issue.
You can't change a variable type from character to numeric in the same datastep. So you already have a variable DOB that's character so you need to change that somehow, or rename it before you import it.
Have you tried an input function instead?
DATA Logins;
SET SASUSER.NTBPLRC (rename=dob=_dob);
DOB_TEMP = TRANWRD(_DOB, "0:0:0. 0", "");
DOB = MDY(SCAN(DOB_TEMP,2,"-"), SCAN(DOB_TEMP,3,"-"), SCAN(DOB_TEMP, 1,"-"));
dob2=datepart(input(_dob, anydtdtm.));
FORMAT DOB dob2 DATE9. ;
RUN;
You can't change a variable type from character to numeric in the same datastep. So you already have a variable DOB that's character so you need to change that somehow, or rename it before you import it.
Have you tried an input function instead?
DATA Logins;
SET SASUSER.NTBPLRC (rename=dob=_dob);
DOB_TEMP = TRANWRD(_DOB, "0:0:0. 0", "");
DOB = MDY(SCAN(DOB_TEMP,2,"-"), SCAN(DOB_TEMP,3,"-"), SCAN(DOB_TEMP, 1,"-"));
dob2=datepart(input(_dob, anydtdtm.));
FORMAT DOB dob2 DATE9. ;
RUN;
Oh yes, Its working......
thanks alot
but again why do I need to rename it?
Because DOB is a character variable. You can't switch it to a date/numeric variable. You either need to give your input or output variable a new name.
DATA Logins;
SET SASUSER.NTBPLRC (rename=dob=_dob);
DOB_TEMP = TRANWRD(_DOB, "0:0:0. 0", "");
DOB = MDY(SCAN(DOB_TEMP,2,"-"), SCAN(DOB_TEMP,3,"-"), SCAN(DOB_TEMP, 1,"-"));
dob2=datepart(input(_dob, anydtdtm.));
FORMAT DOB dob2 DATE9. ;
Age = Round((DATE() - DOB)/365,0);
RUN;
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
It was working perfectly and giving results if I dont use "Round()"
please help
New question, new thread please.
1. You only need one of the the two calculations above, DOB or DOB2
2. If you're trying to calculate age, there are better ways. Search on here for the ideal way to calculate age.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.