0
在一個數據集被創建:SAS切斷字符串中的數據重新編碼
data voa;
input Address $50.;
input City $1-15 State $16-17 Zip;
input Latitude Longitude;
datalines;
1675 C Street, Suite 201
Anchorage AK 99501
61.21 -149.89
600 Azalea Road
Mobile AL 36609
30.65 -88.15
我試圖添加一個新的變量,它是必不可少的龍和緯度的重新編碼,就像這樣:
data voa1;
set voa;
if Longitude < -110 then Region = "West";
if Latitude > 40 and Longitude < -90 and Longitude > -110 then Region = "Mid-West";
if Latitude > 40 and Longitude > -90 then Region = "North-East";
if Latitude < 40 and Longitude < -110 then Region = "South";
run;
不幸的是,似乎SAS正在縮短字符串並將它們留在4個字符處(例如「Mid-West」變成了「Mid-」)。如果我不得不猜測,我會認爲這是因爲SAS根據該列中的第一個值爲列中的每個值分配了一定數量的字節,並且不會根據新值動態修改字節數。我該如何解決?
注意:我認爲潛在的修復可能會首先將最長的潛在輸出(在這種情況下爲「東北」),但這似乎是一個不合理的解決方案。