/* FORMATTED INPUT */ /* Sometimes data comes in a form that must be interpreted before it can be stored. This requires "formatted" input. */ * For example, try to read the following data as list input. Column input does not work either.; * SAS documentation example; data listtry; input item $ amount; cards; trucks 1,382 jeeps 1,235 landrovers 2,391 ; run; proc print data=listtry; run; * Formatted input makes use of a special set of "informat" functions to interpret data as it is read.; data formatted; input item $ 1-16 amount comma5.; cards; trucks 1,382 jeeps 1,235 landrovers 2,391 ; proc print data=formatted; run; * Informats in the input statement behave differently than informats assigned separately. In the first case the informat specifies how many characters are read in, in the second case it specifies a maximum number of characters that are used to form a data value; * Informats and formats are two different things; data formattedlist; informat amount comma5.; format amount dollar9.2; input item $ amount; cards; trucks 1,382 jeeps 1,235 landrovers 2,391 ; proc print data=formattedlist; run; *If you use informats on an input statement, you may also need to use "pointers" to move the cursor through the input buffer; data pointers; input vehicle $ @16 jan comma5. @26 feb comma5. @36 mar comma5.; total = sum(of jan--mar); format total dollar6.0; datalines; trucks 1,382 2,789 3,556 vans 1,265 2,543 3,987 sedans 2,391 3,011 3,658 ; proc print data=pointers; run;