I am trying to convert a numeric year to sas year date. The years are 2013 and 2014. When I have them converted, they are 1965 for both.
This gives me the numeric format for year: year=input(substr(compress(reporting_term,1,4),yy4.);
When I format the year using YEAR4., I am able to get the year formatted, but it gives me 1965.
Any assistance will be great.
SAS doesn't store years as dates. It only stores individual days. If you have a variable that takes on values of 2013, 2014, etc., you can convert them to a legitimate day using:
year = mdy(1, 1, year);
Then the year4 format would print just the year. You're not storing the year, you're storing January 1st of that year. But the format controls what will print.
Good luck.
SAS doesn't store years as dates. It only stores individual days. If you have a variable that takes on values of 2013, 2014, etc., you can convert them to a legitimate day using:
year = mdy(1, 1, year);
Then the year4 format would print just the year. You're not storing the year, you're storing January 1st of that year. But the format controls what will print.
Good luck.
Erm, just store the 2013 as a number as that is all it is. Not sure why you would want a format on that as 2013 = 2013 nothing fancy.
Thank you!! That worked for what I needed!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.