I have a program which has lot of macro calls and i neeed to make a list of existing macro calls in the program.
How can i do that?
any help please
You would be better off modifying the macros. Add %PUT statements that write messages about what the macro is going: beginning execution, creating a data set, ending execution. That's more reliable, and relatively easy to do.
Otherwise, you face many additional complications such as macros that create a data set each time through a loop, macros that call other macros, and extend that idea: macros that call macros that call macros.
You could start by searching the program for all %WORD
Then you'll have to filter out all the automatic macros and possibly any use of % in Like comparisons.
So, you are writing spaghetti code with macro calls all over, and you have no idea of what is in the program - that to me seems to the problem. Software development in any language is all about the planning and the documentation, design your process, define the inputs/outputs, document the features, create a testing plan. Then the final 1% of the whole project is writing some code.
The alternative, and teh way your going is trying to work out what has happened after the event, which is bound to fail. Even if you do pull out all the macro calls - and dont forget you would need the paramters to each of those calls and the context of those macro variables - you would need to know the location of the macro file for those (make sure its the correct version), plus resolve conditional logic within those to understand what parts of the macro were used etc. It can be done, but its a lot of work and is most likely to fail in one way or another.
A final note, there is the proc scaproc procedure which is a code analyser:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a003199745.htm
This encompasses your code and produces ouput for inputs/outputs/macros - it may help reduce the amount of work you have to do, however a good and robust SDLC process would more or less eliminate the need for this at all.
Thanks. Basically its a program which creates multiple datasets by macro calls. I can manually pick up the macro calls and make a list but looking for sas code which can pick calls in the program which starts with "%" and list them in a list file
Well, I can't see the process your doing so can't really say much, however why is the code creating many datasets, which you don't know what they are? Would it not be better to have one dataset output with a by group separator, or outputs datasets, with a consistent prefix. Various ways round it. Again, its all about planning and documentation. A documented process will show inputs/outputs.
You would be better off modifying the macros. Add %PUT statements that write messages about what the macro is going: beginning execution, creating a data set, ending execution. That's more reliable, and relatively easy to do.
Otherwise, you face many additional complications such as macros that create a data set each time through a loop, macros that call other macros, and extend that idea: macros that call macros that call macros.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.