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);


sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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