BookmarkSubscribeRSS Feed
Sanjay_M
Obsidian | Level 7

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.

13 REPLIES 13
PeterClemmensen
Tourmaline | Level 20

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 🙂

Sanjay_M
Obsidian | Level 7

The purpose is to create a macro and hand it over to business users who can execute and produce basic summaries by passing parameters

Reeza
Super User

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

 

delete_sas_studio.png

 

PaigeMiller
Diamond | Level 26

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

 

delete_sas_studio.png

 


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;
--
Paige Miller
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Reeza
Super User

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.


 

Sanjay_M
Obsidian | Level 7

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

Reeza
Super User

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

Sanjay_M
Obsidian | Level 7

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.

PaigeMiller
Diamond | Level 26

@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)??

--
Paige Miller
Sanjay_M
Obsidian | Level 7

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.

Tom
Super User Tom
Super User

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

Reeza
Super User
Tom, do you know if anyone is moving those macro's somewhere else? I'm surprised that site is still up and working.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 13 replies
  • 2314 views
  • 7 likes
  • 5 in conversation