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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

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

View solution in original post

4 REPLIES 4
data_null__
Jade | Level 19

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

Rick_SAS
SAS Super FREQ

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

rkong13
Calcite | Level 5

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!

Rick_SAS
SAS Super FREQ

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;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 2589 views
  • 6 likes
  • 3 in conversation