convert sas date format
On Jan 27, 2012, at 18:58 , David Winsemius wrote:
On Jan 27, 2012, at 10:45 AM, Fischer, Felix wrote:
Hi everybody, i have a csv-file, containing dates in an akward sas format, where 31.12.1559 is -1, 1.1.1960 is 1, 2.1.1960 is 2 and so on (see http://www.sfu.ca/sasdoc/sashtml/lrcon/zenid-63.htm ). Is there any function in R to convert this into YYYY-M-D easily?
Seems as though as.Date should do it, assuming that's a typo for the first date. You just need to change the default origin setting:
as.Date( c(-1,0,1), origin="1960-01-01")
[1] "1959-12-31" "1960-01-01" "1960-01-02"
There are also typos for the two other dates (SAS _does_ have a date number zero). David's code is right.
Best, Felix
-- David Winsemius, MD West Hartford, CT
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com