Unfortunately, dates in SAS are a bit hard to understand, and I have seen a lot of people having trouble trying to make sense of them, specially those whitout a strong technical background and who are not so familiar with complex programming structures. However if you are fluent in Perl regular expressions and C pointers, then SAS dates should be piece of cake!
In order to simplify the understanding of SAS formats, I put together a little piece of code with all the usual conversions between SAS, Oracle and Human readable formats (typically YYYYMMDD), which serves as a reference table to know how we convert from one format to another.
/* From human-readable format YYYYMMDD to SAS and Oracle */ data test_dates; mydate = '20111201'; mydate_sas = input(mydate, yymmdd8.); mydate_oracle = dhms(mydate_sas, 0,0,0); run;
/* From SAS to Oracle and YYYYMMDD*/ data fechas; mydate_sas = today(); mydate = put(mydate_sas, yymmddn8.); mydate_oracle = dhms(mydate_sas, 0,0,0); run;
/* From Oracle to SAS and YYYYMMDD */ data fechas; set oracle_table; mydate_sas = datepart(mydate_oracle); mydate = put(mydate_sas, yymmddn8.); run;
No hay comentarios:
Publicar un comentario