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

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.

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