|
Hello to all on thh list: I have a string variable with content like: UCAYALI / CORONEL PORTILLO CUSCO / CALCA LIMA METROPOLITANA / LIMA I need to create two new variables, extracting the text befor and after the "/" The firts variable content would look like: UCAYALI CUSCO LIMA METROPOLITANA And the second: CORONEL PORTILLO CALCA LIMA Could somebody help me with the sintax for this? Thanks Andrés Mg. Andrés Burga León Coordinador de Análisis e Informática Unidad de Medición de la Calidad Educativa Ministerio de Educación del Perú Calle El Comercio s/n (espalda del Museo de la Nación) Lima 41 Perú Teléfono 615-5840 |
|
Administrator
|
Here are some hints. 1. Use the CHAR.INDEX function to find the position of "/" in your string variable 2. Use CHAR.SUBSTR extract the desired sub-strings from the original string variable. You will need the position computed in part 1 for this. 3. Use LTRIM and RTRIM to trim off leading or trailing blanks. There should be examples of how to use all these functions in the Help files.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
|
In reply to this post by ANDRES ALBERTO BURGA LEON
Dear Andres,
Presuming that '/' is surrounded by a space on each side, try something like data list free/v1(a30). begin data 'CAYALI / CORONEL PORTILLO' 'CUSCO / CALCA' 'LIMA METROPOLITANA / LIMA' end data. str v2 v3 (a20). comp v2=sub(v1,1,ind(v1,'/')-1). comp v3=sub(v1,ind(v1,'/')+2). exe. Best regards, Ruben Date: Mon, 11 Jan 2010 17:32:53 -0500 From: [hidden email] Subject: Extracting and modifiying string variable To: [hidden email] Hello to all on thh list: I have a string variable with content like: UCAYALI / CORONEL PORTILLO CUSCO / CALCA LIMA METROPOLITANA / LIMA I need to create two new variables, extracting the text befor and after the "/" The firts variable content would look like: UCAYALI CUSCO LIMA METROPOLITANA And the second: CORONEL PORTILLO CALCA LIMA Could somebody help me with the sintax for this? Thanks Andrés Mg. Andrés Burga León Coordinador de Análisis e Informática Unidad de Medición de la Calidad Educativa Ministerio de Educación del Perú Calle El Comercio s/n (espalda del Museo de la Nación) Lima 41 Perú Teléfono 615-5840 Express yourself instantly with MSN Messenger! MSN Messenger |
| Free forum by Nabble | Edit this page |
