BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tianerhu
Pyrite | Level 9
data CCA;
b = '2Jan1583'd;
run;
proc print data = CCA;
format  b weekdate31.;
run;

tianerhu_0-1629330182074.png

why it is 'NOV'  ?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@tianerhu wrote:

I am sorry . the year is not 1583 , is 1582 , the following is the revised code :

data CCA;
b = '1Jan1582'd;
run;
proc print data = CCA;
format  b weekdate31.;
run;

tianerhu_0-1629334228318.png

 


 

From the documentation on dates:

SAS can perform calculations on dates ranging from A.D. November 1582 to A.D. 19,900.
 
In other words, none of the functions such as determining the day of week are really guaranteed to work before Nov 1582 reliably.
 
Try this for some interesting results in Jan 1582.
data CCA;
 do b = '1Jan1582'd to '15Nov1582'd ;
   output;
 end;
run;
proc print data = CCA;
format  b weekdate31.;
run;
 

View solution in original post

11 REPLIES 11
tarheel13
Rhodochrosite | Level 12

It's not? 

 

I ran your code and this is what I get in SAS ODA.

 

 
Obs b
1 Sunday, January 2, 1583
ballardw
Super User

@tarheel13 wrote:

It's not? 

 

I ran your code and this is what I get in SAS ODA.

 

 
Obs b
1 Sunday, January 2, 1583

Same with SAS 9.4.4

tianerhu
Pyrite | Level 9

I am sorry . the year is not 1583 , is 1582 , the following is the revised code :

data CCA;
b = '1Jan1582'd;
run;
proc print data = CCA;
format  b weekdate31.;
run;

tianerhu_0-1629334228318.png

 

tarheel13
Rhodochrosite | Level 12

Okay. I see the same as you. But why are you using a date from the 1500s? 

tianerhu
Pyrite | Level 9
I just want to try . Thank you for your help.
tarheel13
Rhodochrosite | Level 12

Okay. If you use different years like 1982 or 2003, it won't show 'NOV' at the beginning.

tianerhu
Pyrite | Level 9
yes, you are right.
From 1582.1.1---1582.1.9, it displays the wrong value .
tarheel13
Rhodochrosite | Level 12

Well, the good news is I feel like it is pretty unlikely that you would ever work with date values from the 1500s loll.

tianerhu
Pyrite | Level 9
yes, i agree with you.
ballardw
Super User

@tianerhu wrote:

I am sorry . the year is not 1583 , is 1582 , the following is the revised code :

data CCA;
b = '1Jan1582'd;
run;
proc print data = CCA;
format  b weekdate31.;
run;

tianerhu_0-1629334228318.png

 


 

From the documentation on dates:

SAS can perform calculations on dates ranging from A.D. November 1582 to A.D. 19,900.
 
In other words, none of the functions such as determining the day of week are really guaranteed to work before Nov 1582 reliably.
 
Try this for some interesting results in Jan 1582.
data CCA;
 do b = '1Jan1582'd to '15Nov1582'd ;
   output;
 end;
run;
proc print data = CCA;
format  b weekdate31.;
run;
 
tianerhu
Pyrite | Level 9
Thank you for your help.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 1234 views
  • 1 like
  • 3 in conversation