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

Greeting!

 

I receieved a SAS program codes which has a few Marco statements.

 

%setup;

......

......

......

%sumcat5(datin=adqs3, clsvar=trt01pn, byvars=avisitn, anvar=aval);

......

......

......

 

When I run the code, I got the following warning and error message when I come to the above Marco statement. 

WARNING: Apparent invocation of macro SETUP not resolved.

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

I don't know much about the Marco, I want to know how I can run the code and what is missing 

 

Thanks 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Yes. 

 

From the name it sounds like they have system of macros they have created.  So the SETUP macro will set your SAS session into the standard environment that they like to use.  Probably defining standard libref, filerefs, options etc.

 

Hopefully they have documentation of how they work and how you can use them.

View solution in original post

12 REPLIES 12
novinosrin
Tourmaline | Level 20

%setup  is a macro call that you would use to execute compiled macro code.

 

Do you know whether

%macro setup;

-------

-----

%mend setup;

 

Has been compiled previously ?

zimcom
Pyrite | Level 9

I dont know, but how?

novinosrin
Tourmaline | Level 20

Hmm, you would need to find out the location where the macro is stored/saved. Perhaps, you could ask your teammates/or even boss? 🙂

ballardw
Super User

Somewhere you need to find the code that define the macro setup. Then compile that before running the code you show.

 

The code would look something like:

 

%macro setup();

<a bunch of statements>

%mend;

 

Highlight the code and then run it to compile the macro. You may need to do this for other macro definitions as well.

If you can't find that definition code go back to the source and search or inquire about the definition code.

zimcom
Pyrite | Level 9

So I need to go back to the original SAS programmer who initially wrote this SAS program to ask for Marco setup code?

Tom
Super User Tom
Super User

Yes. 

 

From the name it sounds like they have system of macros they have created.  So the SETUP macro will set your SAS session into the standard environment that they like to use.  Probably defining standard libref, filerefs, options etc.

 

Hopefully they have documentation of how they work and how you can use them.

zimcom
Pyrite | Level 9

@Tom @novinosrin @ballardw  This is very helpful and I will reach out to the original programmer and find out if he can send me the Marco setup file. Thank you all again, your continuous help and support make my SAS learning possible. 

zimcom
Pyrite | Level 9

 

%sumcat5(datin=adqs3, clsvar=trt01pn, byvars=avisitn, anvar=aval);

 

"Yes, that summarizes the data and puts it in a format for the .rtf file. It is not required for the proc logistic analysis. You can get the summary statistics by replacing it with a proc freq."

 

@ballardw @Tom @novinosrin 

I got reply and not quite sure how to replace the above marco with a proc freq, would you be able to provide any insight on this?

 

 

Tom
Super User Tom
Super User

@zimcom wrote:

 

%sumcat5(datin=adqs3, clsvar=trt01pn, byvars=avisitn, anvar=aval);

 

"Yes, that summarizes the data and puts it in a format for the .rtf file. It is not required for the proc logistic analysis. You can get the summary statistics by replacing it with a proc freq."

 

@ballardw @Tom @novinosrin 

I got reply and not quite sure how to replace the above marco with a proc freq, would you be able to provide any insight on this?

 

 


You need to ask more or figure out what output you want .  Looks like you might use the DATIN value as the DATA= value, BYVARS values on a BY statement, CLSVAR and ANVAR in the TABLES statement.

proc freq data=adqs3 ;
  by avisitn;
  tables trt01pn*aval;
run;
Tom
Super User Tom
Super User

Before you can call %SETUP you need to define it.

 

Most likely the original user was using autocall facility to have SAS find and compile the macro source.  You can set the SASAUTOS option to point to one or more directories and when SAS does not already have a macro with the name your code is using, say SETUP, defined it will look for a file with the same name as the macro, so 'setup.sas',  in the SASAUTOS search path and include the code in that file. 

 

Or there might be one large file that defines all of the macros that the program assumed had already been run when the SAS session was started.

 

So look for the code that starts with %MACRO SETUP and ends with %MEND statement.  That is the definition or the macro.  If you run that code it should just compile the macro so that is available to be called.  Once the macro is defined your other code can use it.

 

ballardw
Super User

@Tom wrote:

Before you can call %SETUP you need to define it.

 

Most likely the original user was using autocall facility to have SAS find and compile the macro source.  You can set the SASAUTOS option to point to one or more directories and when SAS does not already have a macro with the name your code is using, say SETUP, defined it will look for a file with the same name as the macro, so 'setup.sas',  in the SASAUTOS search path and include the code in that file. 

 

Or there might be one large file that defines all of the macros that the program assumed had already been run when the SAS session was started.

 

So look for the code that starts with %MACRO SETUP and ends with %MEND statement.  That is the definition or the macro.  If you run that code it should just compile the macro so that is available to be called.  Once the macro is defined your other code can use it.

 


A Comment I often place in my code that uses some of my custom utility macros is that the macros are in a folder that has been added to the Autocall path on my system. So folks that come after me when I strike it rich at the lottery have some chance of finding the code.

 

Of course they may have to find my Autoexec.SAS file to find that path ...

zimcom
Pyrite | Level 9
Thanks for the insight, after today’s discussion I kind of have an idea of Marco code now. I have requested from the original programmer for the marco code. I am solo SAS user in the entire company and I learned a lot of things from here, I just want to say that I appreciated your help so much !!!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 12 replies
  • 828 views
  • 0 likes
  • 4 in conversation