Solved
Contributor
Posts: 21

# Function MDY()

I have problem dealing with function mdy().

When I try to evaluate mdy(4,1,2012), I get wrong answer in a 64bit system with SAS9.2. Specifically, mdy(4,1,2012)='01MAR2012'd after formatting in date9.. However, if I try to evaluate in a 32bit system with SAS9.1.3, I get correct answer, i.e., '01APR2012'd. Can someone please help? Thank you.

Accepted Solutions
Solution
‎05-29-2012 12:40 PM
Posts: 3,805

## Re: Function MDY()

Are you telling the whole story?  Are you using integer constants or variables?  As you can see from this example you can create a variable that SAS will show as 4 but MDY thinks is 3.

18 data _null_;

19 m = 4-1e-12;

20 x = mdy(m,1,2012);

21 put m= x=date9.;

22 run;

m=4 x=01MAR2012

All Replies
Solution
‎05-29-2012 12:40 PM
Posts: 3,805

## Re: Function MDY()

Are you telling the whole story?  Are you using integer constants or variables?  As you can see from this example you can create a variable that SAS will show as 4 but MDY thinks is 3.

18 data _null_;

19 m = 4-1e-12;

20 x = mdy(m,1,2012);

21 put m= x=date9.;

22 run;

m=4 x=01MAR2012

SAS Super FREQ
Posts: 3,832

## Re: Function MDY()

I think _NULL_ has identified the likely problem. Try x=mdy(round(month), 1, 2012);

Contributor
Posts: 21

## Re: Function MDY()

Thank you very much, both of you, data_null_ and Rick. You are absolutely right! Interesting, 32bit and 64bit (or maybe SAS9.1.3 and SAS9.2) work a slightly differently!

SAS Super FREQ
Posts: 3,832

## Re: Function MDY()

It's the 64-bits.  Loops/iteration like the following "surprise me" more often on 64-bits:

data _null_;

j = 0;

do i = 0 to 1 by 0.1;

month = i*10;

d = month-j; /* mathematically, this is 0, but not numerically */

put d 20.18;

j = j +1;

end;

run;

🔒 This topic is solved and locked.