SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

%macro?

Accepted Solution Solved
Reply
Super Contributor
Posts: 297
Accepted Solution

%macro?

Hi, all:

 

I saw several codes written from previous programmer.  Could someone let me know what they are refering to? Thanks.

 

Y

 

%including "file-specification"/source2;

%rename (uned., _3);

 

%including "file-specification"/source2;

%state (uned., _4);

 

%including "file-specification"/source2;

%report (uned., _5);

 

 


Accepted Solutions
Solution
‎05-18-2017 01:15 PM
Trusted Advisor
Posts: 1,128

Re: %macro?

It is one way of using the macro calls (sas programs) which are located in some location and you want to use them in your current program.

%include is used to refer to the location where the macro program is located and source2 causes the SAS log to show the source statements that are being included in your SAS program.

%rename is the macro call which is being referred in the %include statement.

But i wonder why the %include statemnet has the sas program name as _3_rename.sas and %macro call name is %rename I am expecting the %include should refer to the rename.sas programs file.
Thanks,
Jag

View solution in original post


All Replies
Super Contributor
Posts: 297

Re: %macro?

I specify the %including code:

 

%including "\\test\_3_rename.sas"/source2;

%rename (uned., _3);

 

%including "\\test\_4_state.sas"/source2;

%state (uned., _4);

 

%including "\\test\_5_report.sas"/source2;

%report (uned., _5);

Super User
Super User
Posts: 7,392

Re: %macro?

I don't think that is the exact code is it.  The first:

%including "file-specification"/source2;

Is not correct, correct syntax is:

%include "file-specification" / source2;

 

This loads the given text file and inserts the text at the point of include.

 

The other three are calls to user built macros.  As I am not on your system, can't see any of it, I cannot state anything other than that.

Super Contributor
Posts: 297

Re: %macro?

Yes.  I apologize my typo.  It's %include.

Super User
Posts: 6,928

Re: %macro?

You should post the real code you have questions about. "%including" is not valid SAS syntax.

 

That said, %include tells SAS to fetch the file and place its contents where the %include was.

The other lines seem to call macros from those files.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎05-18-2017 01:15 PM
Trusted Advisor
Posts: 1,128

Re: %macro?

It is one way of using the macro calls (sas programs) which are located in some location and you want to use them in your current program.

%include is used to refer to the location where the macro program is located and source2 causes the SAS log to show the source statements that are being included in your SAS program.

%rename is the macro call which is being referred in the %include statement.

But i wonder why the %include statemnet has the sas program name as _3_rename.sas and %macro call name is %rename I am expecting the %include should refer to the rename.sas programs file.
Thanks,
Jag
Super User
Posts: 10,466

Re: %macro?


Jagadishkatam wrote:
But i wonder why the %include statemnet has the sas program name as _3_rename.sas and %macro call name is %rename I am expecting the %include should refer to the rename.sas programs file.

@Jagadishkatam I've seen file naming conventions like that when they were used to indicate the Order that scipts or programs should be run. I'm not saying it's a good practice but I've seen that.

Super Contributor
Posts: 297

Re: %macro?

Hi,

 

If %rename is the macro call which is being referred in the %include statement.  It shouldn't be use semicolom, it should be just

 

%rename

 

Am I right?

Trusted Advisor
Posts: 1,128

Re: %macro?

you can always call macro calls either with or without semicolon
Thanks,
Jag
☑ This topic is SOLVED.

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

Discussion stats
  • 8 replies
  • 264 views
  • 4 likes
  • 5 in conversation