I have a study that has a starting point of 1998. I also have the variable "event date" which consists of a number either +/- the starting point. I would like to convert this number into "year of event" to determine in what year after 1998 the event occurred. Is there a way to easily code this?
Use SAS date functions, shift the starting point date by event date days and get what year that is :
starting_point = '25OCT1998'd;
year = year(intnx("DAY", starting_point, event_date));
PG
data want;
set have;
event=event_date+starting_point;
year = year(event);
run;
hope this code will solve your issue.
Sudeer.
Whist the above two answers are completely correct, I am questioning what the question is. You state you have a starting point of 1998, which is fine. It is this event date variable which I am not sure on. Does this reference a time interval from the year or something else. I.e. does it contain days since 1998, years since then, quarters, or is it something completely adhoc such as category 2 indicates 5 years.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.