sas SAS Formats Using informats to read data


Example

Informats are used to tell SAS how to read in the data and are identified with an informat statement.

data test;
 infile test.csv;
 informat     id $6.
              date mmddyy10.
              cost comma10.2
 ;
 input @1 id
       @7 date
       @20 cost
 ;
run; 

Informats and Formats can also be used together to read in the data and write it out in a different format such as with the salary variable below:

DATA workers;
  informat first last $16.;
  informat salary 12.1;
  informat birthdate 8.;
  input 
    first $ 
    last $ 
    birthdate 
    salary;
  format salary dollar10.;
datalines;
John Smith 19810505 54998.5
Jane Doe 19950925 45884.5
Frank James 19600222 70000.5
Jamie Love 19630530 292000.5
;
run;