SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading Raw Data in Fixed Fields
Using Informats


Data Step Processing of Informats

Let's place our INPUT statement in the context of a DATA step and submit it for processing. Remember that, after the DATA step is submitted, it is compiled and then executed.

     data perm.empinfo;
        infile empdata;
        input @9 FirstName $5. @1 LastName $7. +7 JobTitle 3.
              @19 Salary comma9.;
     run;                  
During the compile phase, the character variables in the program data vector are defined with the exact length specified by the informat. But notice that the lengths defined for JobTitle and Salary in the program data vector are different from the lengths specified by their informats.

              123 123456789
1---+----10---V-V-V20---+-V-
EVANS   DONNY 112 29,996.63 
HELMS   LISA  105 18,567.23 
HIGGINS JOHN  111 25,309.00 


Program Data Vector

Remember, by default, SAS software stores numeric values (no matter how many digits the value contains) as floating point numbers in 8 bytes of storage. The length of a stored numeric variable is not affected by an informat's width or other column specifications in an INPUT statement.

However, it is still necessary to specify the actual width of a raw data field in an INPUT statement. Otherwise, if you specify a default field width of 8 for all numeric values, you'll get inappropriate variable values when the program executes.

In the example below, the values for JobTitle would contain embedded blanks, thus creating invalid numeric values.

     data perm.empinfo;
        infile empdata;
        input @9 FirstName $5. @1 LastName $7.            
              +7 JobTitle 8. @19 Salary comma8.;
     run; 
              12345678
                  12345678
1---+----10---V---V20V--+V--
EVANS   DONNY 112 29,996.63 
HELMS   LISA  105 18,567.23 
HIGGINS JOHN  111 25,309.00 


Program Data Vector


back||next


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

Terms of Use & Legal Information | Privacy Statement