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

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)

1 ACCEPTED SOLUTION

Accepted Solutions
spjcdc
Calcite | Level 5

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

3 REPLIES 3
Tom
Super User Tom
Super User

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;

spjcdc
Calcite | Level 5

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

cypher85
Calcite | Level 5

Thanks guys, all very helpful!

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1502 views
  • 0 likes
  • 3 in conversation