Sample 24644: Reading data using formatted input
Read in data using informats for a file with no delimiters.
Note:
With formatted input, an informat follows a variable name
and defines how SAS reads the values of this variable. An
informat gives the data type and the field width of an input
value. Informats also read data that are stored in nonstandard
form, such as packed decimal, or numbers that contain special
characters such as commas.
Generally, SAS represents missing values in formatted input
with a single period for a numeric value and with blanks for a
character value. The informat that you use with formatted
input determines how SAS interprets a blank. For example,
$CHAR.w reads the blanks as part of the value, whereas BZ.w
converts a blank to zero.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/* Create sample data. Note there are no delimiters, each field begins */
/* in the same place on each record. */
data acctinfo;
input acctnum $8. date mmddyy10. amount comma9.;
format date mmddyy10.;
datalines;
0074309801/15/2001$1,003.59
1028754301/17/2001$672.05
3320899201/19/2001$702.77
0345900601/19/2001$1,209.61
;
proc print;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
OBS ACCTNUM DATE AMOUNT
1 00743098 01/15/2001 1003.59
2 10287543 01/17/2001 672.05
3 33208992 01/19/2001 702.77
4 03459006 01/19/2001 1209.61
Read in data using informats for a file with no delimiters.
Type: | Sample |
Topic: | SAS Reference ==> DATA Step Common Programming Tasks ==> Reading and Writing External Data
|
Date Modified: | 2019-06-11 15:00:49 |
Date Created: | 2004-09-30 14:09:00 |
Operating System and Release Information
SAS System | Base SAS | All | n/a | n/a |