BookmarkSubscribeRSS Feed
Kiteulf
Quartz | Level 8

I have this code: which generates missing months between dates. eg:

However I want to force the the second current month, which today will be July.

1idChar200
2dateNum8YYMMN6.
3_TYPE_Num8
4_FREQ_Num8
5spendNum8

INPUT ID $200. date yymmn6. _TYPE_ 8. _FREQ_ 8. spend 8.;


Datalines;

2572294 201202 3 1 1

2572294 201210 3 1 1

2572294 201211 3 1 1

2572294 201307 3 1 1

2572294 201312 3 1 1

2572294 201404 3 1 1

2572294 201405 3 1 1;

run;


summary nway data= utsett99( keep= id spend date ) ;


class   id date ;


var     spend ;


output  sum= out= summary1 ;


;


monthly_data  ;* add rows for months with no spend ;


set summary1 ;


by id ;



if first.id then priordate= date ;


output ;


. ;




do while( intck( 'month', date, target) > 1) ;


'month', date, 1) ;


output ;


end ;


keep id spend date ;


;

2 REPLIES 2
ballardw
Super User

It might help to show us what you expect for output. And your posted code has lots of stuff missing so can't really comment on that either. You may need to paste into a plain text editor such as Notepad before copy and paste to this site.

Astounding
PROC Star

Getting the month prior to the current month is relatively easy.  What am I missing?

prior_month = intnx('month', today(), -1);


hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

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