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...
I | base_month | m1 | m2 | m3 | m4 | m5 | m6 |
1 | 201401 | 201402 | 201403 | 201404 | 201405 | 201406 | 201407 |
2 | 201402 | 201403 | 201404 | 201405 | 201406 | 201407 | 201408 |
3 | 201403 | 201404 | 201405 | 201406 | 201407 | 201408 | 201409 |
4 | 201404 | 201405 | 201406 | 201407 | 201408 | 201409 | 201410 |
5 | 201405 | 201406 | 201407 | 201408 | 201409 | 201410 | 201411 |
6 | 201406 | 201407 | 201408 | 201409 | 201410 | 201411 | 201412 |
7 | 201407 | 201408 | 201409 | 201410 | 201411 | 201412 | 201501 |
8 | 201408 | 201409 | 201410 | 201411 | 201412 | 201501 | 201502 |
9 | 201409 | 201410 | 201411 | 201412 | 201501 | 201502 | 201503 |
10 | 201410 | 201411 | 201412 | 201501 | 201502 | 201503 | 201504 |
11 | 201411 | 201412 | 201501 | 201502 | 201503 | 201504 | 201505 |
12 | 201412 | 201501 | 201502 | 201503 | 201504 | 201505 | 201506 |
13 | 201501 | 201502 | 201503 | 201504 | 201505 | 201506 | 201507 |
14 | 201502 | 201503 | 201504 | 201505 | 201506 | 201507 | 201508 |
15 | 201503 | 201504 | 201505 | 201506 | 201507 | 201508 | 201509 |
16 | 201504 | 201505 | 201506 | 201507 | 201508 | 201509 | 201510 |
17 | 201505 | 201506 | 201507 | 201508 | 201509 | 201510 | 201511 |
18 | 201506 | 201507 | 201508 | 201509 | 201510 | 201511 | 201512 |
19 | 201507 | 201508 | 201509 | 201510 | 201511 | 201512 | 201601 |
20 | 201508 | 201509 | 201510 | 201511 | 201512 | 201601 | 201602 |
21 | 201509 | 201510 | 201511 | 201512 | 201601 | 201602 | 201603 |
22 | 201510 | 201511 | 201512 | 201601 | 201602 | 201603 | 201604 |
23 | 201511 | 201512 | 201601 | 201602 | 201603 | 201604 | 201605 |
24 | 201512 | 201601 | 201602 | 201603 | 201604 | 201605 | 201606 |
25 | 201601 | 201602 | 201603 | 201604 | 201605 | 201606 | 201607 |
26 | 201602 | 201603 | 201604 | 201605 | 201606 | 201607 | 201608 |
27 | 201603 | 201604 | 201605 | 201606 | 201607 | 201608 | 201609 |
28 | 201604 | 201605 | 201606 | 201607 | 201608 | 201609 | 201610 |
29 | 201605 | 201606 | 201607 | 201608 | 201609 | 201610 | 201611 |
30 | 201606 | 201607 | 201608 | 201609 | 201610 | 201611 | 201612 |
31 | 201607 | 201608 | 201609 | 201610 | 201611 | 201612 | 201701 |
32 | 201608 | 201609 | 201610 | 201611 | 201612 | 201701 | 201702 |
33 | 201609 | 201610 | 201611 | 201612 | 201701 | 201702 | 201703 |
34 | 201610 | 201611 | 201612 | 201701 | 201702 | 201703 | 201704 |
35 | 201611 | 201612 | 201701 | 201702 | 201703 | 201704 | 201705 |
36 | 201612 | 201701 | 201702 | 201703 | 201704 | 201705 | 201706 |
37 | 201701 | 201702 | 201703 | 201704 | 201705 | 201706 | 201707 |
38 | 201702 | 201703 | 201704 | 201705 | 201706 | 201707 | 201708 |
39 | 201703 | 201704 | 201705 | 201706 | 201707 | 201708 | 201709 |
40 | 201704 | 201705 | 201706 | 201707 | 201708 | 201709 | 201710 |
41 | 201705 | 201706 | 201707 | 201708 | 201709 | 201710 | 201711 |
42 | 201706 | 201707 | 201708 | 201709 | 201710 | 201711 | 201712 |
43 | 201707 | 201708 | 201709 | 201710 | 201711 | 201712 | 201801 |
44 | 201708 | 201709 | 201710 | 201711 | 201712 | 201801 | 201802 |
45 | 201709 | 201710 | 201711 | 201712 | 201801 | 201802 | 201803 |
46 | 201710 | 201711 | 201712 | 201801 | 201802 | 201803 | 201804 |
47 | 201711 | 201712 | 201801 | 201802 | 201803 | 201804 | 201805 |
48 | 201712 | 201801 | 201802 | 201803 | 201804 | 201805 | 201806 |
49 | 201801 | 201802 | 201803 | 201804 | 201805 | 201806 | 201807 |
50 | 201802 | 201803 | 201804 | 201805 | 201806 | 201807 | 201808 |
51 | 201803 | 201804 | 201805 | 201806 | 201807 | 201808 | 201809 |
52 | 201804 | 201805 | 201806 | 201807 | 201808 | 201809 | 201810 |
53 | 201805 | 201806 | 201807 | 201808 | 201809 | 201810 | 201811 |
54 | 201806 | 201807 | 201808 | 201809 | 201810 | 201811 | 201812 |
55 | 201807 | 201808 | 201809 | 201810 | 201811 | 201812 | 201901 |
56 | 201808 | 201809 | 201810 | 201811 | 201812 | 201901 | 201902 |
Is there a way to create a Macro that will help me run this code so many times?
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.
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!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.