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!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.