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.
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.