BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alam_ather
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

6 REPLIES 6
Reeza
Super User

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;

alam_ather
Calcite | Level 5

Oh yes, Its working......

thanks alot Smiley Happy

alam_ather
Calcite | Level 5

but again why do I need to rename it?

Reeza
Super User

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.

alam_ather
Calcite | Level 5

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

Reeza
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 2455 views
  • 0 likes
  • 2 in conversation