ALIGN= Data Set Option

specifies variable alignment.

Valid in: DATA step and PROC step
Default: YES
Restriction: Use only with SPD Server
Engine: SPD Engine only

Syntax

ALIGN=YES | NO

Required Arguments

YES

enables variable alignment.

NO

disables variable alignment to allow the SPD Engine data set to be compatible with the SPD Server.

Details

Variable Alignment

Base SAS imposes proper numeric data alignment on an observation on disk by the careful arrangement of the variables within the observation. Like the default Base SAS engine, the SPD Engine ensures that all of the numeric values are grouped together at the beginning of the observation. It also ensures that the total observation length is an even multiple of 8-bytes by adding extra-padding bytes at the end of the observation when necessary. The SAS memory system ensures that all allocated memory starts on an 8-byte boundary and that all of the numeric values are 8 bytes long. Grouping the numeric values together at the beginning of the observation ensures that they will all be properly aligned and can be used directly from the memory.
An observation in an SPD Engine data set is read from disk into memory. All of the bytes are read at once, and their relative alignment is maintained in memory. For maximum performance when accessing that observation data, all numeric data values need to be properly aligned. Therefore, the need to move the values to a new location is avoided. The normal behavior of the SPD engine is to ensure that all of the numeric values in an observation are aligned on an 8-byte boundary when written to disk. This allows the SPD engine to retrieve the observation data from disk and store it in memory. The SPD Engine application uses the observation data directly from that location without the need to move it.

Using the SPD Server

The SPD Server does not support the data alignment feature. Data sets created by the SPD Engine that are used by the SPD Server must be created with data alignment disabled. Using the ALIGN=NO option causes the data stored in the data set to not be aligned. As a result, the data must be moved from its original memory location that it was read into and into a different memory location that is aligned.
The purpose of the ALIGN=NO data set option is to specify that no data alignment is done by the SPD Engine. This is not useful in most situations, but it is necessary when using the SPD Server. The SPD Server does not support variable alignment capability. In some situations, the SPD Server will refuse to operate on a data set that has aligned variables.
CAUTION:
Do not use the ALIGN=NO option unless the data set is destined for the SPD Server.
Unaligned variable data will cause a significant decrease in performance when processed by Base SAS.

Examples

Example 1: Data Set with Variable Alignment

The first data set shows the default behavior—it has aligned variables. Note that the observation length is not the sum of the variable lengths. The observation length has been rounded up to be an even multiple of 8. Also, the variables have been rearranged so that the numeric variables come first in the observation.
Data Set with Variable Alignment
data testdata.size;
   length text $10   width 8    chars 8;
   text='Zero';      width=1;   chars=4;  output;
   text='Ten';       width=2;   chars=3;  output;
   text='Twenty';    width=2;   chars=6;  output;
run;

NOTE: The data set TESTDATA.SIZE has 3 observations and 3 variables.

proc sql;
   select obslen
   from dictionary.tables
   where memname="SIZE";


   Observation
        Length
   -----------
            32

   select  varnum, name, npos, length
   from dictionary.columns
   where memname="SIZE"
   order by npos;

     Column
     Number                                      Column    Column
   in Table  Column Name                       Position    Length
   --------------------------------------------------------------
          2  width                                    0         8
          3  chars                                    8         8
          1  text                                    16        10

quit;

/* ------------------------------------------------------------------- */

data testdata.size (align=no);
   length text $10   width 8    chars 8;
   text='Zero';      width=1;   chars=4;  output;
   text='Ten';       width=2;   chars=3;  output;
   text='Twenty';    width=2;   chars=6;  output;
run;

NOTE: The data set TESTDATA.SIZE has 3 observations and 3 variables.

Example 2: Data Set without Variable Alignment

The second data set is identical except that the variables are not aligned. Note that the observation length is just the sum of the variable lengths. The observation length is not rounded to an even multiple of 8-bytes. The variables appear in the order in which they were encountered in the DATA step in the LENGTH statement. The variables were not rearranged for alignment.
Data Set without Variable Alignment
data testdata.size (align=no);
   length text $10   width 8    chars 8;
   text='Zero';      width=1;   chars=4;  output;
   text='Ten';       width=2;   chars=3;  output;
   text='Twenty';    width=2;   chars=6;  output;
run;

NOTE: The data set TESTDATA.SIZE has 3 observations and 3 variables.

proc sql;
   select obslen
   from dictionary.tables
   where memname="SIZE";

   Observation
        Length
   -----------
            26

   select varnum, name, npos, length
   from dictionary.columns
   where memname="SIZE"
   order by npos;


     Column
     Number                                      Column    Column
   in Table  Column Name                       Position    Length
   --------------------------------------------------------------
          1  text                                     0        10
          2  width                                   10         8
          3  chars                                   18         8
quit;

NOTE: The data set TESTDATA.SIZE has 3 observations and 3 variables.