Hi,
I've a data step below, which converts a "wide" table to a "narrow" table. The code in Listing 1 runs fine. However, when I try to make a macro for the same code (see Listing 2), and try to run it. SAS does nothing. No error is given. In fact, I'm unable to submit any other SAS code and have to restart SAS.
Please advise what mistake I am making. Thank you in advance for your help!
Asim
Listing 1:
data MFHoldings_Yield;
format CUSIP $9. Yield_Date mmddyy10.;
set MFHoldingsRaw_Yield;
array Yield_Data{&no_of_yield.} Yield_1 - Yield_&no_of_yield.;
Yield_date=&start_date_yield.-1;
do i=1 to &no_of_yield.;
if not missing(Yield_Data{i}) then do;
Yield_date=Yield_date+i;
Yield=Yield_Data{i};
output;
end;
end;
keep CUSIP Yield_Date Yield;
run;
Listing 2:
%macro createYieldTable(dsn1, dsn2);
data &dsn2.;
format CUSIP $9. Yield_Date mmddyy10.;
set &dsn1.;
array Yield_Data{&no_of_yield.} Yield_1 - Yield_&no_of_yield.;
Yield_date=&start_date_yield.-1;
do i=1 to &no_of_yield.;
if not missing(Yield_Data{i}) then do;
Yield_date=Yield_date+i;
Yield=Yield_Data{i};
output;
end;
end;
keep CUSIP Yield_Date Yield;
run;
%macro createYieldTable;
%createYieldTable(MFHoldingsRaw_Yield, MFHoldings_Yield);
You should end your macro definition by a %mend statement, not another %macro.
You should end your macro definition by a %mend statement, not another %macro.
Linus, many thanks!
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.
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.