- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I think _NULL_ has identified the likely problem. Try x=mdy(round(month), 1, 2012);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;