Date: Thu, 29 Nov 2001 08:48:42 -0800
Reply-To: Stephen Arthur <sarthur67@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Stephen Arthur <sarthur67@YAHOO.COM>
Subject: SAS MACRO / SAS ARRAY question!
Content-Type: text/plain; charset=us-ascii
Hi,
Here is my question with comments and SAS code:
* 1) SAS transposes data &file to get ;
* observedProportion for each month as a variable;
proc transpose data=&file out=trans&file;
by indicator_text NAME centerLine nObservation
FIRSTDate LASTDate NUMBERMonths;
id date;
var observedProportion;
run;
* 2) SAS transposes data &file to get month as a;
* variable;
proc transpose data=&file out=date&file;
by indicator_text NAME centerLine nObservation;
var date;
run;
* 3) SAS joins the two output files which allows;
* observedProportion and month to be accessed in the ;
* same SAS array, see DATA step below;
proc sql;
create table trans&file
as select *
from trans&file f1
left join date&file f2
on f1.indicator_text = f2.indicator_text
and f1.NAME = f2.NAME
order by f1.indicator_text, f1.NAME;
quit;
* 4) I need to create starting and ending variable ;
* names for the two arrays, because the length of ;
* an array may varying in its starting and ending ;
* and the array may also have missing values that ;
* can alter the length of the NUMBERMonths variable;
data trans1&file &eightMONTHS.&file;
set trans&file;
by indicator_text NAME;
* array of proportions;
array x{*} &FIRSTDate-numeric-&LASTDate;
********** *********;
* array of months;
array y{*} COL1-COL&NUMBERMonths;
*************;
***************************************************;
***** leaving out a whole bunch of data steps *****;
***************************************************;
run;
* SAS solved this problem using a fixed macro;
* variables for FIRSTDate, LASTDate, and
NUMBERMonths,;
* but now I have data that varies per by value in the;
* starting and ending points and may have missing ;
* values as well;
* Does anyone have a good solution to this problem: ;
* Having the arrays in data step have varying values;
* depending on the by statement?;
Thanks,
Stephen
__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1