03-04-2018 07:47 PM
I am trying to calculate the difference in days between dates. More specifically between the values of variable Date and January 1, 2000.
Here it is my code and I have attached the data set:
PROC IMPORT OUT= work.NBA
PROC PRINT DATA=work.NBA;
PROC PRINT DATA = NBA;
FORMAT Date WORDDATE. ;
fecha = intck('day', DATE, "01Jan2000"d);
PROC PRINT DATA=NBA;
03-04-2018 08:08 PM
Your data has some dates before year 2000, and some after. So when you calculate the difference, which years should show a negative difference and which a positive difference?
Your formula calculates the number of days as negative for years after 2000. It's easy to reverse that, and you don't need any functions to do it:
fecha = date - '01jan2000'd;
And yes, you do need a SET statement.
Need further help from the community? Please ask a new question.