No need to apologize. SAS is a very different thought process that takes a lot of practice. You're asking all the right questions.
SAS is an iterative language. The array of numbers you are speaking of sounds like many individual observations within a dataset. SAS performs operations on values one row at a time within each dataset, then moves onto the next row once it hits the bottom of a data step.
Assuming your dataset looks like this:
var
1
2
3
4
If you wanted to square each number, you would create a new variable (or you can overwrite the current variable, your choice) and use the **
exponent operator.
data want;
set have;
var_squared = var**2;
run;
In this step, SAS creates a dataset want
, reads the dataset have
, creates a new numeric variable of length 8 named var_squared
, assigns it a value of var*var
, then outputs. It repeats the read-calculate-write cycle for each row until it hits the end of file marker. Note that output
is implied automatically. When you do not specify output
, SAS will automatically write to the new dataset once it hits run
.
Your new dataset will look like this:
var var_squared
1 1
2 4
3 9
4 16