|
How do I denote a wildcard in a five character wide field?
As an example, if * were a wildcard and I wrote 250** I would expect to select all data with 250 in the first three positions and anything else in the next two positions. Here's what I really want to do. I have 15 variables, xx1 to xx15, side by side. I want to find if 254** or 2344* or 3366* is found in any of variable columns 1-15. A record line might have more than one scattered along the 15 columns or just one found in V15. I just want to know if it occurs in that record. I will crosstab the findings. Here's my attempt: The syntax below only finds the exact data i.e. '254' and not '254**' vector v1=xx1 to xx15. loop #i=1 to 15. do if (any(v1(#i),'2344 ','254 ','3366 ')). compute positive=1. break. end if. end loop. Many thanks, Gary ===================== 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 |
|
Gary,
I think no wildcards can be used. Try this vector v1=xx1 to xx15. loop #i=1 to 15. do if (any(substr(v1(#i),1,4),'2344','3366') or substr(v1(#i),1,3) eq '254'). compute positive=1. break. end if. end loop. It's not quite elegant, but it should work... Greetings Frederic Villamayor, BS Researcher/Study Manager Biostatistics Unit Juan de Sada, 32 08028 Barcelona (Spain) Tel +34 935 093 236 Fax +34 934 112 764 [hidden email] http://www.ferrergrupo.com ¿Necesita imprimir este mensaje? Protejamos el medio ambiente. Li cal imprimir aquest missatge? Protegim el medi ambient. Do you need to print this message? Let's protect the environment. Este mensaje, y en su caso, cualquier fichero anexo al mismo, puede contener información confidencial, siendo para uso exclusivo del destinatario, quedando prohibida su divulgación, copia o distribución a terceros sin la autorización expresa del remitente. Si Vd. ha recibido este mensaje erróneamente, se ruega lo notifique al remitente y proceda a su borrado. Gracias por su colaboración. This message and its annexed files may contain confidential information which is exclusively for the use of the addressee. It is strictly forbidden to distribute copies to third parties without the explicit permission of the sender. If you receive this message by mistake, please notify it to the sender and make sure to delete it. Thank you for your kind cooperation. Gary Stevens <[hidden email]> Enviado por: "SPSSX(r) Discussion" <[hidden email]> 29/09/2008 23:43 Por favor, responda a Gary Stevens <[hidden email]> Para [hidden email] cc Asunto [SPSSX-L] widcards How do I denote a wildcard in a five character wide field? As an example, if * were a wildcard and I wrote 250** I would expect to select all data with 250 in the first three positions and anything else in the next two positions. Here's what I really want to do. I have 15 variables, xx1 to xx15, side by side. I want to find if 254** or 2344* or 3366* is found in any of variable columns 1-15. A record line might have more than one scattered along the 15 columns or just one found in V15. I just want to know if it occurs in that record. I will crosstab the findings. Here's my attempt: The syntax below only finds the exact data i.e. '254' and not '254**' vector v1=xx1 to xx15. loop #i=1 to 15. do if (any(v1(#i),'2344 ','254 ','3366 ')). compute positive=1. break. end if. end loop. Many thanks, Gary ===================== 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 |
|
In reply to this post by Gary Stevens-2
Gary,
From your syntax it looks like the variables are string variables, and the characters you want to select on are always in the leading positions. In that case you can use the SUBSTR function. In your syntax below try replacing the do line by Do if ( SUBSTR(v1(#i),1,4) = '2344' | SUBSTR(v1(#i),1,4) = '3366' | SUBSTR(v1(#i),1,3) = '254' ). Garry Gelade -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gary Stevens Sent: 29 September 2008 22:43 To: [hidden email] Subject: widcards How do I denote a wildcard in a five character wide field? As an example, if * were a wildcard and I wrote 250** I would expect to select all data with 250 in the first three positions and anything else in the next two positions. Here's what I really want to do. I have 15 variables, xx1 to xx15, side by side. I want to find if 254** or 2344* or 3366* is found in any of variable columns 1-15. A record line might have more than one scattered along the 15 columns or just one found in V15. I just want to know if it occurs in that record. I will crosstab the findings. Here's my attempt: The syntax below only finds the exact data i.e. '254' and not '254**' vector v1=xx1 to xx15. loop #i=1 to 15. do if (any(v1(#i),'2344 ','254 ','3366 ')). compute positive=1. break. end if. end loop. Many thanks, Gary ===================== 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 __________ NOD32 3481 (20080929) Information __________ This message was checked by NOD32 antivirus system. http://www.eset.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 |
| Free forum by Nabble | Edit this page |
