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.
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
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
I think _NULL_ has identified the likely problem. Try x=mdy(round(month), 1, 2012);
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!
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;
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!
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.