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

sas-innovate-2024.png

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.

 

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