BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

data _NULL_;

CALL SYMPUTx('mth1',put(intnx('year',today(),-1,'b'),monyy5.),'g') ;

CALL SYMPUTx('mth12',put(intnx('year',today(),-1,'e'),monyy5.),'g') ;

run;

Output is JAN19 and Dec19 respectively

 

I am attempting to get remaining months exactly 1 full year ago starting with Jan19

How would I be able to use the same logic for say FEB19, MAR19...etc.

 

3 REPLIES 3
PaigeMiller
Diamond | Level 26

You need a different call to INTNX(). For example, 11 months earlier would use:

 

intnx('month',today(),-11)

--
Paige Miller
ballardw
Super User

@Q1983 wrote:

data _NULL_;

CALL SYMPUTx('mth1',put(intnx('year',today(),-1,'b'),monyy5.),'g') ;

CALL SYMPUTx('mth12',put(intnx('year',today(),-1,'e'),monyy5.),'g') ;

run;

Output is JAN19 and Dec19 respectively

 

I am attempting to get remaining months exactly 1 full year ago starting with Jan19

How would I be able to use the same logic for say FEB19, MAR19...etc.

 


I have to say I do not understand what you mean by "remaining months". or what the actual desired output for a given input is here.

 

Normally "remaining months" to me would be a number of months left after removing or some interval. So for "exactly 1 full year" that would tend to be 12 months?!?

If you expect to create date incrementing months then I would expect to see an interval unit of 'month'.

yabwon
Onyx | Level 15

Hi,

 

try this:

data _NULL_;
  do i = 0 to 11;
    CALL SYMPUTx(cats('mth',i+1),put(intnx('month',today(),-12+i,'b'),monyy5.),'g');
  end;
run;
%put _user_;

 

All the best

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



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
  • 3 replies
  • 615 views
  • 0 likes
  • 4 in conversation