Is there any SAS date format that displays the current month and year in full?
For example, the current value should be April 2020
I tried worddate. format but it gives me day as well which I don't need.
data test1;
a=put(today(),worddate.);
run;
output: April 28, 2020
I need : April 2020
I don't know of a format that gives you exactly what you want. But if you start with WORDDATX instead of WORDDATE, it will be easier to extract the pieces you want.
Proc Format will allow you to make a large number of custom formats using the Picture with directives and indicating that the data is expected to be a date, time or datetime value.
proc format ;
picture mymonthyear (default=15)
low-high = '%B %Y' (datatype=date)
;
run;
data example;
do month=1 to 12;
date = mdy(month,1,2020);
put 'Date is ' date mymonthyear.;
end;
run;
The default= is to determine the default number of characters to display. If not included the formats tend to be 8 characters and a tad short. Depending on exact desired use you may need to use the -L (left justify) with Put.
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.