GirlL
GirlL

Reputation: 1

Converting SAS date to month indexing system

How can I convert the month and year of a date to match a variable named by a month indexing system used in a study where January 1986 is month 1? I need to create a variable that calculates the difference between the current month and Jan 1986 but am not sure how to get started. My dates are currently in YYYYMMDD format.

Upvotes: 0

Views: 77

Answers (1)

Joe
Joe

Reputation: 63424

The intck function tells you how many intervals of something occur between two dates.

monthnum = intck('month','01JAN1986'd, surveydate);

If you only have month/year, you can use the mdy function to construct a date.

dtvar = mdy(monthvar,1,yearvar);

Upvotes: 1

Related Questions