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!
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.
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.