SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading Raw Data in Fixed Fields
Record Formats


Reading Variable Length Records

When you are working with variable-length records that contain fixed-field data, you may have values that are shorter than others or that are missing.This can cause problems when you attempt to read the raw data into your SAS data set.

For example, notice that the INPUT statement specifies a field width of 8 columns for TotalReceipts. In the third record, the input pointer encounters an end-of-record marker before the 8th column.

     input Department $ 1-11 @13 TotalReceipts comma8.;

The asterisk symbolizes the end-of-record marker and is not part of the data.

                   12345678
1---+----10---+---V20--
BED/BATH    1,354.93*  
HOUSEWARES  2,464.05*  
GARDEN      923.34*    
GRILL       598.34*    
SHOES       1,345.82*  
SPORTS*                
TOYS        6,536.53*  


The input pointer moves down to the next record in an attempt to find a value for TotalReceipts. However, Grill is a character value and TotalReceipts is a numeric variable. Thus, an invalid data error occurs and TotalReceipts is set to missing.


V---+----10---+----20--
BED/BATH    1,354.93*  
HOUSEWARES  2,464.05*  
GARDEN      923.34*    
GRILL       598.34*    
SHOES       1,345.82*  
SPORTS*                
TOYS        6,536.53*  



back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement