Sample 24773: Using _TEMPORARY_ arrays
The sample code on the Full Code tab illustrates how to use temporary array elements to hold values that will be used to populate existing data set variable values.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/* Create sample data */
data test;
input var1 var2 var3;
datalines;
10 20 30
100 . 300
. 40 400
;
/* The _TEMPORARY_ array values are used to populate the missing values */
/* in the TEST data set. The data set variables are put into an array and */
/* there is a one to one correlation between the existing values and the values */
/* in the _TEMPORARY_ array. A DO loop is used to evaluate if the value is */
/* missing and if so, assign the new value. */
data new(drop=i);
set test;
array newval(3)_TEMPORARY_ (.1 .2 .3) ;
array now(3) var1 var2 var3;
do i=1 to 3;
if now(i)=. then now(i)=newval(i);
end;
run;
proc print;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
OBS VAR1 VAR2 VAR3
1 10.0 20.0 30
2 100.0 0.2 300
3 0.1 40.0 400
Use temporary array elements to hold values that will be used to populate existing data set variable values.
Type: | Sample |
Topic: | SAS Reference ==> DATA Step Data Management ==> Manipulation and Transformation ==> Array processing
|
Date Modified: | 2005-12-08 11:34:32 |
Date Created: | 2004-09-30 14:09:12 |
Operating System and Release Information
SAS System | Base SAS | All | n/a | n/a |