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!
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.