08-23-2016 08:29 AM
i have a variable in the dataset and it has characters which start with a weird space or square like thing.
I need to remove it whereever it is there in the variable list. Can any one help me in it.
08-23-2016 08:37 AM
First I'd recommend to convert the contents of your variable to a new variable of double length with a $hex format.
Assuming that oldvar is $6:
newvar = put(oldvar,$hex12.);
Now you can determine what exactly is behind the funny symbol, and can use that hex code to decide when the first character should be stripped using the substr() function and when not. Use the hex code in a literal as "NN"x (NN being hex digits 0-9,a-f)
08-23-2016 08:48 AM
Yes, But not all variables have that funny symbol in the start.
For example see the screenshot. but for some variables it is proper.
08-23-2016 08:52 AM
Since this is program code, it looks to me like the result of a failed character code conversion when transferring the file from one system to another.
08-23-2016 09:31 AM
The rectangle means it is a non printable character and is not in your font set of characters.
I would start with searching the origin of data because removing characters means you change the data.
On your capture I saw 0 to 2 rectangles and maybe there are more, even in middle of a variable;
Those can be different characters, not neccessary the same one;
in case you recognize specific hexa characters you can replace then to any character(s) you chose
using TRANSLATE function:
ne_var = translate(old_var, new_chars, old_chars);
new_chars and old_chars should fit by order.
08-23-2016 08:38 AM
you can remove 1st character by:
var = substr(var,2);
Do you know the origin of your data? how did you get the variable with that extra character ?
Need further help from the community? Please ask a new question.