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

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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