Date: Wed, 22 Apr 2009 15:35:47 -0400
Reply-To: D T <sasandstats@LIVE.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: D T <sasandstats@LIVE.COM>
Subject: macro question-using list of variables?
Content-Type: text/plain; charset="iso-8859-1"
I have been stuck with this several times before--can you suggest how to resolve this?
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 repetitive.
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 meas4;
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 (sex-time).
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Ū: Now available on your iPhone or BlackBerry