SAS cutting off string during data recode -
on dataset created by:
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
i'm attempting add new variable essential recoding of long , lat, so:
data voa1; set voa; if longitude < -110 region = "west"; if latitude > 40 , longitude < -90 , longitude > -110 region = "mid-west"; if latitude > 40 , longitude > -90 region = "north-east"; if latitude < 40 , longitude < -110 region = "south"; run;
unfortunately, seems sas cutting strings short , leaving them @ 4 characters (e.g. "mid-west" becomes "mid-"). if had guess assume because sas assigns number of bytes each value in column based on first value in column, , doesn't dynamically modify number of bytes based on new values. how fix this?
note: think potential fix might putting longest potential output (in case "north-east") first, seems inelegant solution.
one of nice features of sas not forced define variables before using them. if don't define variable sas must make guess @ meant code write. in case since first reference new variable region
in assignment statement:
region = "west"
sas makes logical decision define character variable of length 4.
to fix add length
statement before first if
statement.
length region $10;
Comments
Post a Comment