Date: Wed, 22 Apr 2009 16:03:53 -0400
Reply-To: Jack Clark <jclark@HILLTOP.UMBC.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jack Clark <jclark@HILLTOP.UMBC.EDU>
Subject: Re: macro question-using list of variables?
Content-Type: text/plain; charset="us-ascii"
Do you have to have separate reports for each BY variable-Measure
combination? If not, consider a CLASS statement with all of your BY
variables, a VAR statement with your measures, and a WAYS statement
requesting only reports on single BY variables (not on the interactions
between BY variables).
proc means data = a;
class sex p agroup rgroup system loc time;
Senior Research Analyst
University of Maryland, Baltimore County
Sondheim Hall, 3rd Floor
1000 Hilltop Circle
Baltimore, MD 21250
Confidentiality Notice: This e-mail may contain information that is legally privileged and that is intended only for the use of the addressee(s) named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying of this e-mail, distribution, or action taken in reliance on the contents of this e-mail and/or documents attributed to this e-mail is strictly prohibited. If you have received this information in error, please notify the sender immediately by phone and delete this entire e-mail. Thank you.-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of D T
Sent: Wednesday, April 22, 2009 3:36 PM
Subject: macro question-using list of variables?
I have been stuck with this several times before--can you suggest how to
I have 7 variables in a data set I need to use as by variables on a proc
means, and I need to create means from 4 variables in the same data set.
This sounds like it should be resolvable in a macro because it is so
I can create a macro for which I would subsequently switch out the means
variable, and the by variables, but I have not been able to figure out
how to feed the two sets of variables to two lists that a macro would
run through, and use one variable after the other.
Here is a simplified example of my data:
input sex $ p agroup rgroup $ system $ loc $ time meas1 meas2 meas3
F 1 2 W C1 R 1 3 5 1 2
F 0 2 W C3 U 3 1 1 2 1
M 0 2 B C2 U 2 4 7 2 3
F 0 3 W C2 R 1 3 3 7 5
M 0 4 O C1 U 1 1 3 5 2
I can get a simple macro together like this:
proc sort data=a;
proc means data=a;
title "means by &bvarnm for &varnm";
etc.... until I have created means for meas1-meas4 by all 7 by groups
But isn't there a way that I could make a macro loop through my list of
by variables, and run a proc means with each of the 7 by variables, and
run through a second list of my four meas variables?
Thanks for your help!
Rediscover Hotmail(r): Now available on your iPhone or BlackBerry