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

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 584 views
  • 0 likes
  • 2 in conversation