Help using Base SAS procedures

Help with Macro error

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

Help with Macro error

When I try to run this macro, I get this error.  Anyone know how to write the macro to essentially do the same function and have it run successfully?

"ERROR: The macro RENAMES generated CARDS (data lines) for the DATA step, which could cause

       incorrect results.  The DATA step and the macro will stop executing."

%macro renames(sec);

data &sec ;

    input ( original newname) (:$32.);

cards;

Mapped_name    Online_Name

B9_    submitdate

run;

%MEND renames;

options mprint;

%renames(renames)


Accepted Solutions
Solution
‎03-27-2012 02:10 PM
Contributor
Posts: 27

Help with Macro error

The simple way to do it is to replace the cards statement with assignment statements and an output statement such as this:

data &sec ;

length original newname $32 ;

original = 'Mapped_Name' ; newname = 'Online_Name' ; output ;

original = 'B9_' ; newname='submitdate' ; output ;

run ;

It sounds like you may have other things that you want to do because what you have here doesn't require a macro. 

Steve

View solution in original post


All Replies
Super User
Super User
Posts: 6,500

Help with Macro error

You cannot use CARDS in a macro.  There are tricks using external files and %include to do something like it.

Based on your previous post about the rename macro I would recommend using either

A) Store your list in a permanent dataset that is maintained outside of the macro.

B) Use a FORMAT to do the rename.

proc format ;

   value $rename

   'B9_' = 'submitdate'

...

   ;

run;

Solution
‎03-27-2012 02:10 PM
Contributor
Posts: 27

Help with Macro error

The simple way to do it is to replace the cards statement with assignment statements and an output statement such as this:

data &sec ;

length original newname $32 ;

original = 'Mapped_Name' ; newname = 'Online_Name' ; output ;

original = 'B9_' ; newname='submitdate' ; output ;

run ;

It sounds like you may have other things that you want to do because what you have here doesn't require a macro. 

Steve

Contributor
Posts: 23

Help with Macro error

Thanks guys, all very helpful!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 225 views
  • 0 likes
  • 3 in conversation