BookmarkSubscribeRSS Feed
hua
Obsidian | Level 7 hua
Obsidian | Level 7

Hi, 

 

I used the code:

%let start_date=01Jan0001;
%let end_date=31Dec2013;
data Date;
do date="&start_date"d to "&end_date"d;
output;
end;
format date date9.;
run;

data YMD;
set Date;
Year=year(date);
month=month(date);
day=day(date);
drop date;
run;

 

But, SAS don't recognize the date before 1600-01-01.

Does anyone know how to solve this?

 

Thanks!

7 REPLIES 7
Tom
Super User Tom
Super User

Why do you want to store invalid dates?

Are you using them as some type of special missing value?  If so then pick a different date that can be stored in a SAS date variable.

Otherwise just work with your dates as either strings or three separate year, month and day variables.

hua
Obsidian | Level 7 hua
Obsidian | Level 7
Not the missing value. I'm dealing with GCM data. The time format is the days after 0001-01-01. I want to check if the data I use are the coresponding date. 🙂 Thanks
kannand
Lapis Lazuli | Level 10

Not sure I'm clear on the exact issue you mentioned....

 

" I want to check if the data I use are the coresponding date."

 

Would you be able to elaborate with an example of the challenge you have?

Kannan Deivasigamani
PGStats
Opal | Level 21

It becomes very messy to deal with pre-18th century dates, before the adoption of our regular calendar. SAS will not do that for you.

 

About SAS Date, Time, and Datetime values

 

 

If you really need them, use year, month, day values and good luck Smiley Happy

PG
hua
Obsidian | Level 7 hua
Obsidian | Level 7
Thanks.
Yes, SAS could only recognize the dates after 1600.
I did this in excel. 🙂
PGStats
Opal | Level 21

This is what I would try. If the foreign date system considers 01-01-0001 as day zero then foreignDate-584388 should give you the corresponding SAS date. If 01-01-0001 is day one then that expression should be foreignDate-584389.

 

-584388 is '01JAN1600'd - '01JAN3200'd

PG
ballardw
Super User

@hua wrote:
Thanks.
Yes, SAS could only recognize the dates after 1600.
I did this in excel. 🙂

You need to double check what Excel may have done. It doesn't recognize dates by default before 1900, at least on my install. I suspect you ended up with a TEXT value in Excel not an actual date. See what happens if you change the cell format in Excell to display a different date format.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 4962 views
  • 0 likes
  • 5 in conversation