Reading Free-Format Data | |
Changing the Length of Character Values
|
Remember that when you use list input to read raw data,
character values are assigned a default length of 8. Let's
take a look at what happens when list input is used to read character values
that have a value longer than 8.
The raw data file referenced by the fileref Citydata contains 1970 and 1980 population figures for several large U.S. cities. Notice that some city names are rather long. |
ANCHORAGE
48081 174431
ATLANTA
495039 425022
BOSTON
641071 562994
CHARLOTTE
241420 314447
CHICAGO
3369357 3005072
DALLAS
844401 904078
DENVER
514678 492365
DETROIT
1514063 1203339
MIAMI
334859 346865
PHILADELPHIA
1949996 1688210
SACRAMENTO
257105 275741
The longer character values are truncated when they are written to the program data vector. |
Output for the data set shows the truncated values for
City . |
data perm.growth; infile citydata; input City $ Pop70 Pop80; run; proc print data=perm.growth; run; |
Obs | City | Pop70 | Pop80 |
1 | ANCHORAG | 48081 | 174431 |
2 | ATLANTA | 495039 | 425022 |
3 | BOSTON | 641071 | 562994 |
4 | CHARLOTT | 241420 | 314447 |
5 | CHICAGO | 3369357 | 3005072 |
6 | DALLAS | 844401 | 904078 |
7 |
DENVER | 514678 |
492365 |
8 |
DETROIT | 1514063 |
1203339 |
9 |
MIAMI | 334859 |
346865 |
10 |
PHILADEL | 1949996 |
1688210 |
11 | SACRAMEN | 257105 | 275741 |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.