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!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: