Hi,
I have the below macro variable which outputs 1202.
%Let yymm = %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),-1,end)),yymmn4.));
Now I want to use the above macro variable(&yymm.) and output ONLY the year in YYYY format(2012).
%Let yyyy = %sysfunc(year(&yymm.));
I tried the above step and it is giving me 1963 as output. Can someone take a look?
Thanks in advance!.
It worked!!!. Thanks Karl..
%let yyyy = %sysfunc(year(%sysfunc(inputn(&yymm,yymmn4.))));
HTH,
Karl
It worked!!!. Thanks Karl..
Macro var &yymm contains a string like 1209. The year function expects a SAS date value (date expressed as number of days since 1/1/1960).
1209 days is a date in the year 1963.
If you want to use the year function then you née first to convert you string back to a SAS date (using a information - not sure if there is one for your date format).
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.