Fay, Arrays in SAS data steps come in a few flavours.
1/ They can be used just a convenience to treat values in the current input vector by a single name. ( as you have in your example ). 2/ As a temporary location for calculations. As such it is not saved to the output data set - unless you code it up to do so. If you wanted to do your calcs within a data step you could do something like the example below. On the other hand you could just read the data into a dataset and run PROC IML to give you array handling abilities. As another way to go you could use APL to do all the array stuff you ever wanted to do. Ian Ian Shannon Environmental Information & Statistics Unit Environment Protection Authority 59 Goulburn Street Sydney PO Box A290 Sydney South NSW 1232 Australia e-mail [EMAIL PROTECTED] Phone (+61 2) 9995 5490 Fax (+61 2) 9995 5926 ================================================================= Example SAS code. ================================================================= data AllData(keep=Oxygen RunTime RunPulse); retain row 0; * Used as row counter ; input Oxygen RunTime RunPulse; ** Remember the number of rows we have read *; row = row + 1; call symput("nrows", put(row, 8.0)); datalines; 44.609 11.37 178 39.442 13.08 174 45.313 10.07 185 60.055 8.63 170 51.855 10.33 166 49.156 8.95 180 39.407 12.63 174 46.080 11.17 156 45.790 10.47 186 50.545 9.93 148 48.673 9.40 186 47.920 11.50 170 47.467 10.50 170 ; run; %put nrows = &nrows; %* Macro variable nrows set so that the array size in next dataset is correct *; data TryAgain(keep=Oxygen RunTime RunPulse); set AllData end=last; retain row 0; * Used as row index ; ** Define our incore array of data *; array AllData(&nrows, 3) _TEMPORARY_ ; ** define array to overlay the input vector *; array OneRow(3) Oxygen RunTime RunPulse; row = row + 1; * row counter ; * Now transfer the input data into in-core matrix ; DO col = 1 to 3; AllData(row, col) = OneRow(col); end; ** Check if all the data has been read in by now *; if last then do; /* your processing which works on array AllData goes in here */ /* eg ... */ DO row = 1 to &nrows; DO col = 1 to 3; x=rand('uniform'); if (x<0.1) then AllData(row ,col) = 0; end; end; * Now write all data out to the TryAgain dataset ; do row = 1 to &nrows; do col = 1 to 3; OneRow(col) = AllData(row, col); end; output; * writes out OneRow into dataset ; end; * End of dataset write ; end; * End of work performed when all data in memory ; run; proc print data=TryAgain; run; ================================================================= -----Original Message----- From: Fay Hughes [mailto:[EMAIL PROTECTED]] Sent: Wednesday, 22 January 2003 4:23 PM To: [EMAIL PROTECTED] Subject: IMPUTE: SAS help required Hi, I am trying to programme several simple imputation techniques (namely unconditional and conditional mean imputation, Healy-Westmacott procedure, Buck's 1960 method as well as regression based methdos) as well as using SAS to do EM and DA. My problem is that I want to read in a completely observed data set and then randomly remove values, and then use the dataset created for analyses. The way I am thinking of programming requires my data set to be in an array format so that I can work with the entire thing, individual values or columns by specifying things like data, data[1,2] and data[1,*]. I amn having problems getting SAS (see code below) to create arrays - any help on this problem, possible SAS codes or places to look on the web for help would all be appreciated. Many thanks Fay Hughes Statistics masters student University of Natal, Durban SAS code (randomly removes values, but does not put the remaining ones into an array) data try; input Oxygen RunTime RunPulse @@; array try2(3,1) Oxygen RunTime RunPulse; DO cols = 1 to 3; DO rows = 1 to 1; x=rand('uniform'); if (x<0.1) then try2(cols,rows)= 0; end; end; datalines; 44.609 11.37 178 39.442 13.08 174 45.313 10.07 185 60.055 8.63 170 51.855 10.33 166 49.156 8.95 180 39.407 12.63 174 46.080 11.17 156 45.790 10.47 186 50.545 9.93 148 48.673 9.40 186 47.920 11.50 170 47.467 10.50 170 ;