BookmarkSubscribeRSS Feed
ivyc
Calcite | Level 5

Hi ,I am new to SAS .

I need to pull statement data by month as of Jan 2014 .

Each month of data 1,2,3,4,5,6,months of performance for base month. (so for Jan 14 I pull Feb,Mar,Apr,May,Jun,Jul 14 data to check performance,for Feb2014 I pull Mar,Apr,May,Jun,Jul, August 2014 , etc.)

I need to do that for January 2014   Aug 18.

Which is 56 months and each month has 6 months pf perf.

Something like this below. For I iteration =1 I have base month and track performance by 6 different dates.

etc...

Ibase_monthm1m2m3m4m5m6
1201401201402201403201404201405201406201407
2201402201403201404201405201406201407201408
3201403201404201405201406201407201408201409
4201404201405201406201407201408201409201410
5201405201406201407201408201409201410201411
6201406201407201408201409201410201411201412
7201407201408201409201410201411201412201501
8201408201409201410201411201412201501201502
9201409201410201411201412201501201502201503
10201410201411201412201501201502201503201504
11201411201412201501201502201503201504201505
12201412201501201502201503201504201505201506
13201501201502201503201504201505201506201507
14201502201503201504201505201506201507201508
15201503201504201505201506201507201508201509
16201504201505201506201507201508201509201510
17201505201506201507201508201509201510201511
18201506201507201508201509201510201511201512
19201507201508201509201510201511201512201601
20201508201509201510201511201512201601201602
21201509201510201511201512201601201602201603
22201510201511201512201601201602201603201604
23201511201512201601201602201603201604201605
24201512201601201602201603201604201605201606
25201601201602201603201604201605201606201607
26201602201603201604201605201606201607201608
27201603201604201605201606201607201608201609
28201604201605201606201607201608201609201610
29201605201606201607201608201609201610201611
30201606201607201608201609201610201611201612
31201607201608201609201610201611201612201701
32201608201609201610201611201612201701201702
33201609201610201611201612201701201702201703
34201610201611201612201701201702201703201704
35201611201612201701201702201703201704201705
36201612201701201702201703201704201705201706
37201701201702201703201704201705201706201707
38201702201703201704201705201706201707201708
39201703201704201705201706201707201708201709
40201704201705201706201707201708201709201710
41201705201706201707201708201709201710201711
42201706201707201708201709201710201711201712
43201707201708201709201710201711201712201801
44201708201709201710201711201712201801201802
45201709201710201711201712201801201802201803
46201710201711201712201801201802201803201804
47201711201712201801201802201803201804201805
48201712201801201802201803201804201805201806
49201801201802201803201804201805201806201807
50201802201803201804201805201806201807201808
51201803201804201805201806201807201808201809
52201804201805201806201807201808201809201810
53201805201806201807201808201809201810201811
54201806201807201808201809201810201811201812
55201807201808201809201810201811201812201901
56201808201809201810201811201812201901201902

Is there a way to create a Macro that will help me run this code so many times?

 

 

2 REPLIES 2
Astounding
PROC Star

There might be a  macro.

 

There might be a short way to do this without macros.

 

But we would need to see what the "before" data looks like.  The you data posted is really a concept of what the "after" result should look like.  So show the "before" picture and there might be a way.

novinosrin
Tourmaline | Level 20

Not sure whether your request is so simple as the below coz like @Astounding pointed out, we do not know the bigger picture. 

 

/*vyc's request i think*/
%let start=	'01jan2014'd;
%let end= '01aug2018'd;
data wvyc;
do j=0 to intck('month',&start, &end);
base=intnx('month',	&start,j);
array m(6);
	do i=1 to dim(m);
	m(i)=intnx('month',base,i) ;
	end;
	output;
end;
format base m:  yymmd.;
drop i;
run;

If the above is not your requirement, i'll follow the thread tomorrow as i'm gonna sleep. Good night from Chicago!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 692 views
  • 0 likes
  • 3 in conversation