BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
asimraja
Fluorite | Level 6

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);

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

You should end your macro definition by a %mend statement, not another %macro.

Data never sleeps

View solution in original post

2 REPLIES 2
LinusH
Tourmaline | Level 20

You should end your macro definition by a %mend statement, not another %macro.

Data never sleeps
asimraja
Fluorite | Level 6

Linus, many thanks! Smiley Happy

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1568 views
  • 0 likes
  • 2 in conversation