BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
BrahmanandaRao
Lapis Lazuli | Level 10
%let date=&sysdate9.;
%put &date;
%let month_year=%sysfunc(inputc("&date",date9.),monyy7.);
%put month_year;

Here i am trying output monyy7. (APR2023) using sysdate9.

required output

APR2023

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@BrahmanandaRao wrote:

hi miller 

it shows only text as below i think macro processor cannot read macro variable 

month_year


Its really unclear what you mean by this. My code works properly. When something doesn't work, you need to show us the code you are using that isn't working. Saying something doesn't work is never sufficient. We don't know what you did, you have to SHOW us. 

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26
%let month_year=%sysfunc(inputn(&date,date9.),monyy7.);
--
Paige Miller
BrahmanandaRao
Lapis Lazuli | Level 10

hi miller 

it shows only text as below i think macro processor cannot read macro variable 

month_year

PaigeMiller
Diamond | Level 26

@BrahmanandaRao wrote:

hi miller 

it shows only text as below i think macro processor cannot read macro variable 

month_year


Its really unclear what you mean by this. My code works properly. When something doesn't work, you need to show us the code you are using that isn't working. Saying something doesn't work is never sufficient. We don't know what you did, you have to SHOW us. 

--
Paige Miller
Tom
Super User Tom
Super User

You are working way too hard.

You have a 9 character string and you want the last 7 characters of it.

644  %let month_year=%substr(&sysdate9,3);
645  %put &=sysdate9 &=month_year ;
SYSDATE9=13APR2023 MONTH_YEAR=APR2023

SAS Innovate 2025: Call for Content

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 483 views
  • 2 likes
  • 3 in conversation