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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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