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
Amethyst | Level 16

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



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