BookmarkSubscribeRSS Feed
srdhoble
Calcite | Level 5

Hi Team,

               Here is what i need help into.

I have two macro definations

Macro1 and Macro2

and they have macro calls as

 

%macro1(a,b,c)

%macro1(a1,b1,c1)

%macro1(a2,b2,c2)

%macro2(p1,q1,r1,s1)

%macro2(p2,q2,r2,s2)

%macro2(p3,q3,r3,s3)

%macro2(p4,q4,r4,s4)

 

Both macro1 and macro2 have proc sql statement within them and output a 2 column 2 row output(1st row headers,which are differant for each macro call and second rows are numeric values.)

 

 

I want to append all results of macro calls(for both tables) into a  SAS dataset.Please help me on this.Thanks!

 

 

5 REPLIES 5
Reeza
Super User

Here are two options. 

 

Option 1: 

Make each macro generate an output table with a unique name and then appemd the results. Use a naming convention, such as a common prefix so that you can use either a colon or list to append all easily. 

 

Data results;

set result1-result10;*appends all tables in between result1, result2, etc;

run;

 

OR 

 

data want;

Set result:; *will append any table starting with the work result;

run; 

 

 

Option 2:

Or have each iteration of the macro append the results to a main result table. If you rerun a section you'll end up,with duplicate results so would need to manage that. 

For this option look at PROC appemd. 

srdhoble
Calcite | Level 5
Hi..thanks for reply,here is what i am trying to do now....i generated
tables with differant names....

So now i have table t1 with columns a,b
table t2 with colums c,d

I want to have table three with following column names and values:
t3 with column name X Y
a b
1 2
c d
2 1
so basically i want to have column headers and column values in t3 from
table t1 and t2.Please guide me on this.TIA

##- Please type your reply above this line. Simple formatting, no
attachments. -##
srdhoble
Calcite | Level 5

Hi..thanks for reply,here is what i am trying to do now....i generated tables with differant names....

 
So now i have table t1 with columns a,b
                        table t2 with colums c,d
 
I want to have table three with following column names and values:
t3  with column name    X Y
                                      a  b
                                      1 2
                                       c d
                                       2 1
so basically i want to have column headers and column values in t3 from table t1 and t2.Please guide me on this.TIA
Reeza
Super User

Make them have the same name in your macro don't fix it after. 

Reeza
Super User

Make them have the same name in your macro don't fix it after. 

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