BookmarkSubscribeRSS Feed
samface
Calcite | Level 5

Hello dear community,

 

I need help aggregating tables using a SAS macro language. 

 

So assuming I have the following  monthly tables 'table_201001, table_201002, table_201003, ..., table_201312' with a variable named 'date_month ' (201001, 201002, 201003, ..., 201312). I would like to create a macro that I can allow me to assess the performance over a period of time. 

 

For example to check the perfo from 201001 to 201003 (numeric values) i create the following macro:

 

%let starting_date=201001;

%let ending_date=201003;

 

proc sql;

create table as table_report as 

select t1,*,t2.date_month

from t1 left join t2 on (t1.x=t2.y)

where t2.date_month between &starting_date. and &ending_date.;

quit;

 

I am trying to create a macro that can generate a perfo using a starting date and include increments like +15 to obtain a ending date. 

 

I tried using intnx('month','20nov2002'd,1,"sameday"); but my values for date_month are numeric. Any suggestions?

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

Your question is confusing.

 

1. What are tables T1 and T2?   Is T1   table_&starting_date

 

2. Only T2 contains the date variable?

 

3. What does the SQL look life for 3 tables? Can you use a data step merge?

 

4. ...include increments like +15...

No idea what this means

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 903 views
  • 0 likes
  • 2 in conversation