Can someone direct me to any user written macros available that can generate PROC SUMMARY on the fly for multiple groups and multiple statistics by passing parameters to the macro like variable, group, stats needed etc.
Why would you want to complicate things with a macro? Just find a PROC SUMMARY online or here at the community and alter it. I'm sure that'll do 🙂
The purpose is to create a macro and hand it over to business users who can execute and produce basic summaries by passing parameters
@Sanjay_M wrote:
The purpose is to create a macro and hand it over to business users who can execute and produce basic summaries by passing parameters
Wouldn't it be more effective to teach them the GUI interface for SAS instead?
The Tasks in SAS Studio or EG can do this, have relatively clear instructions on what goes where and have a point and click interface that's simple to use. The code generated is pretty clean as well, IMO.
@Reeza wrote:
@Sanjay_M wrote:
The purpose is to create a macro and hand it over to business users who can execute and produce basic summaries by passing parameters
Wouldn't it be more effective to teach them the GUI interface for SAS instead?
The Tasks in SAS Studio or EG can do this, have relatively clear instructions on what goes where and have a point and click interface that's simple to use. The code generated is pretty clean as well, IMO.
In the English language, we have a phrase "Please listen to reason". Here in the SAS communities it goes: "Please listen to @Reeza."
The GUI seems to me a much better solution to create a generic macro to call a SAS PROC. I mean, really, is there any particular salient difference between giving users a tool that requires them to type
%summary(data=mydata,
classvars=class1 class2,
vars=x1 x2 x3, ...)
compared to requiring the users to type
proc summary data=mydata;
class class1 class2;
var x1 x2 x3;
...
run;
You mean something like this?
proc summary data=&dsn;
class &classvarnames;
var &varnames;
output out=&outdsn &statistics / autoname;
run;
Yes, I know that isn't truly a macro and &statistics doesn't exactly work, I'm simply asking if this is close to what @Sanjay_M is asking for.
And if you decide you really, really want a macro then you can build one pretty easily.
Follow the steps outlined in this post:
https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md
If macros are totally new, read through this post first:
https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/
@Sanjay_M wrote:
Can someone direct me to any user written macros available that can generate PROC SUMMARY on the fly for multiple groups and multiple statistics by passing parameters to the macro like variable, group, stats needed etc.
Thanks all.
I'm building something on the lines of what PaigeMiller has posted.
But considers, custom formats, preload formats etc.
But thanks for the reply
@Sanjay_M wrote:
Thanks all.
I'm building something on the lines of what PaigeMiller has posted.
But considers, custom formats, preload formats etc.
But thanks for the reply
Are you saying the GUI doesn't support those options somehow? Which features are not supported?
You can add them to the SAS Ballots for suggestions as additions.
Hi Reeza,
The GUI is pretty good, but it is just a requirement that needs coded up.
I am also considering parameterising formats to preload.
@Sanjay_M wrote:
Thanks all.
I'm building something on the lines of what PaigeMiller has posted.
But considers, custom formats, preload formats etc.
Why not just teach the PROC SUMMARY syntax, instead of the Macro syntax (for a macro which doesn't yet exist)??
I agree with you. With the generic macro you could only do basic things easily, unless one writes up a 10 page code that is over complicated and hard to follow.
I am going to keep the macro simple, but stress that the tool needs to be used.
You might want to look at some of the macro suites out there. Like Roland's Spectre system.
http://www.datasavantconsulting.com/roland/Spectre/unistats.html
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.