Dear List,
I have a string variable (A255) which I would like to recode - indicating if the string variable is populated with a value or if the cell is blank/missing (no values are in the cell). After having used the missing values (" ") syntax there are still some blank cells that contain a hidden character when I run a frequency. When I alter type the variable to (AHEX2) I see the following value: 2CA0202020202020, etc. In these cases SPSS treats these cells as if they contain data even though when one examines the cell it is blank. I have tried to replace the space in the variable and that does not work, I have also tried LTRIM and this too does not work. Is there a way to recode variables that are in AHEX format - so far, I gather that the answer is no. Any suggestions on how to address this problem would be much appreciated. Thank you in advance. Damir |
I had some data that was sent in an Excel .xlsx format. Intermittently there were linefeed characters.
When you have weird character you can Google to find the decimal equivalent of hex. There are ways to write this more compactly, but I thought this would be more communicative. *change all linefeeds (Hex A0) to space. string LineFeed(a1). compute Linefeed = string(10,PIB1). do repeat StringVar=v1 to v65. compute StringVar = replace(StringVar,LineFeed," "). end repeat. execute. delete variables Linefeed. I am confused about the hex 2c because it seems that should print a comma. 2C should be decimal 44 which is comma. If it is a comma the REPLACE should work. or you can do something like the above except use compute MysteryVar = string(44,PIB1). If the data came in .xlsx format one cure for that problem was to open the file in excel and save it to .xls format. I have not tested this as I am not where I have SPSS but something as compact as this may work. compute stringVar = replace(StringVar,string(10,PIB1)," ").
Art Kendall
Social Research Consultants |
In reply to this post by DKUKEC
Art may have already responded to your question. I saw an earlier post from him. Perhaps there's better methods but my scheme is to exploit the assumption that the first character of the string almost certainly must be either a letter, a number, or a space. Anything that is not one of those is recomputed to a known character string, e.g., spaces. Thus:
String #x(a1). Compute #x=upcase(char.substr(text_field,1,1)). If (index(#x,'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',1) eq 0) text_field=' '. If by chance you are not using Unicode, there is a shorter way to do this that exploits the ASCII sequence number. These were documented in prior versions of the CSR but no longer. With the change to Unicode they probably no longer apply although it seems plausible that a-z,A-Z,0-9 would occupy a contiguous block. Others know much more on this than I do. Gene Maguin -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of DKUKEC Sent: Wednesday, October 15, 2014 7:24 PM To: [hidden email] Subject: AHEX / Invisible Characters in String Variables? Dear List, I have a string variable (A255) which I would like to recode - indicating if the string variable is populated with a value or if the cell is blank/missing (no values are in the cell). After having used the missing values (" ") syntax there are still some blank cells that contain a hidden character when I run a frequency. When I alter type the variable to (AHEX2) I see the following value: 2CA0202020202020, etc. In these cases SPSS treats these cells as if they contain data even though when one examines the cell it is blank. I have tried to replace the space in the variable and that does not work, I have also tried LTRIM and this too does not work. Is there a way to recode variables that are in AHEX format - so far, I gather that the answer is no. Any suggestions on how to address this problem would be much appreciated. Thank you in advance. Damir -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/AHEX-Invisible-Characters-in-String-Variables-tp5727610.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Free forum by Nabble | Edit this page |