Chapter Contents |
Previous |
Next |
The DATASOURCE Procedure |
The length attribute indicates the number of bytes the SAS System uses for storing the values of variables in output data sets. Therefore, the shorter the variable lengths, the more efficient the disk-space usage. However, there is a trade-off. The lengths of numeric variables are closely tied to their precision, and reducing their lengths arbitrarily can cause precision loss.
The DATASOURCE procedure uses default lengths for series variables appropriate to each file type. For example, the default lengths for numeric variables are 5 for IMFIFSP type files. In some cases, however, you may want to assign different lengths. Assigning lengths less than the defaults reduces memory and disk-space usage at the expense of reduced precision. Specifying lengths longer than the defaults increases the precision but causes the DATASOURCE procedure to use more memory and disk space. The following statements define a default length of 4 for all numeric variables in the IFSFILE and then assign a length of 6 to the exchange rate index:
filename ifsfile 'host-specific-file-name' <host-options>; proc datasource filetype=imfifsp infile=ifsfile interval=month out=exchange outcont=exchvars; where country in ('112','146','158') and partner=' '; keep f_x_am f_x_ah; range from '01jun87'd to '01feb88'd; rename f_x_ah=exrindex f_x_am=effexr; label f_x_ah='F_X_AH: Exchange Rate Index 1985=100' f_x_am='F_X_AM: Effective Exchange Rate(MERM)'; length _numeric_ 4; length f_x_ah 6; run; title1 'Printout of OUTCONT= Showing LENGTH Variable'; proc print data=exchvars noobs; var name label length; run; title1 'Contents of the OUT= Data Set Showing LENGTHs'; proc contents data=exchange; run;
|
The default lengths of the character variables are set to the minimum number of characters that can hold the longest possible value.
Chapter Contents |
Previous |
Next |
Top |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.