| Reading Raw Data in Fixed Fields |
| Using
Informats |
| Reading Nonstandard Numeric Data
The COMMAw.d informat is used to read numeric values and remove embedded
|
|
In the example below, the values for Salary
contain commas, which means that they are nonstandard numeric values.
The values for |
data perm.empinfo;
infile empdata;
input @9 FirstName $5. @1 LastName $7. +7 Jobtitle 3.
@19 Salary
|
EVANS DONNY 112 29,996.63
HELMS LISA 105 18,567.23
HIGGINS JOHN 111 25,309.00
LARSON AMY 113 32,696.78
MOORE MARY 112 28,945.89
POWELL JASON 103 35,099.50
RILEY JUDY 111 25,309.00
| Now add the COMMAw.d informat and specify the field width. The values end in column 27, so the field width is 9 columns. Add a RUN statement to complete the DATA step. |
data perm.empinfo;
infile empdata;
input @9 FirstName $5. @1 LastName $7. +7 JobTitle 3.
@19 Salary comma9.;
run;
|
| 123456789 | ||||||||
|
If you use PROC PRINT to display the data set, the commas
are removed from the values for Salary in the resulting output. |
data perm.empinfo;
infile empdata;
input @9 FirstName $5. @1 LastName $7. +7 JobTitle 3.
@19 Salary comma9.;
run;
proc print data=perm.empinfo;
run;
|
| Obs | FirstName | LastName | JobTitle | Salary |
| 1 | DONNY | EVANS | 112 | 29996.63 |
| 2 | ALISA | HELMS | 105 | 18567.23 |
| 3 | JOHN | HIGGINS | 111 | 25309.00 |
| 4 | AMY | LARSON | 113 | 32696.78 |
| 5 | MARY | MOORE | 112 | 28945.89 |
| 6 | JASON | POWELL | 103 | 35099.50 |
| 7 | JUDY | RILEY | 111 | 25309.00 |
| Thus, the COMMAw.d informat does more than simply read the raw data values. It strips out special characters, such as commas, from numeric data and stores only numeric values in a SAS data set. |
| You can use the EUROw.d informat or the EUROXw.d informat to read numeric values that contain embedded Euro symbols (E) and other special characters. The EUROw.d informat assumes that a decimal point is used as a separator between the whole number and the decimal portion. The EUROXw.d informat assumes that a comma is used as a separator between the whole number and the decimal portion. |
![]() ![]() |
|
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.