BookmarkSubscribeRSS Feed
martasofiasousa
Calcite | Level 5

Hi!

 

I'm using SAS Studio from SAS University Edition through a VirtualBox and I'm trying to write a macro but it seems that the program doesn't recognize the statement. When I try to execute the code nothing happens, not even an error message. Does anyone know what can I do? Or if there is an option I need to activate to the program recognize the macro?

 

Thanks! 

2 REPLIES 2
Reeza
Super User

You need to submit the full macro definition at once and it works fine. Run the following and see what happens.

 

%macro example_print(dsn=);

proc print data=&dsn(obs=5);
run;

%mend;

%example_print(dsn=sashelp.class);

UCLA introductory tutorial on macro variables and macros

https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/

Tutorial on converting a working program to a macro

This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it 🙂 https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md

Examples of common macro usage

https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Ap...

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1136 views
  • 0 likes
  • 3 in conversation