Hi, I am trying to dynamically create tables, using a macro, from a larger table based on the column names (so I don't have to do a 40 select union) . the final goal is a crosstab table. The column names in the source table are like AB1_AccountID AB1_Name AB1_Address AB2_AccountID AB2_Name AB2_Address etc. , 1234 Besty Ross 123 MainSt 34567 Frank N Stein PO BOX 66 I'd like a table of the AB1 data, the AB2 data etc. that looks like Table AB1_Recs AB1_AccountID AB1_Name AB1_Address 12345 Besty Ross 123 Main St 34567 Frank N Stein PO Box 66 .etc... I was trying to use a macro to create the individual datasets : %macro Make40Tabless; %do j=1 %to 40; %LET brnum=BR&j; PROC SQL; create table yaddayadda_ab1 as select "&brnum"||_AccountID from yaddayadda_wrk; run; ... %end; %mend; %Make40Tables I've tried all sorts of variations on having the variables in " and not, and the closest I can get is an error saying the column names BR1, _AccountID are not found in the dataset. What am I doing wrong? Is this really the dorkiest way to do this or is there a better way? I am new to SAS programming, am I making this harder than it has to be? I *might* could do without the individual datasets if it's easier. Thanks Cat
... View more