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)
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
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;
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
Thanks guys, all very helpful!
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.
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.
Ready to level-up your skills? Choose your own adventure.