|
Hi everyone,
I would like to do a filter on a string variable . I would like to select only the cases which contain a comment with a syntax. I have try to make a SELECT IF (StringVar ne "") but the filter don't run. Can you help me ? Thanks Anthony ====================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 |
|
You can do this in python and have multiple comments if you want
begin program Import spss, spssaux CreativeList = {'varname1':['string1','string2','string2'], 'varname2':['string1','string2','string2']} for i in CreativeList.keys(): mylist = CreativeList[i] jvars = "" for j in mylist: vard = spssaux.VariableDict(pattern=".*%s" % j) vVars = vard.variables if len(vVars) > 0: if len(jvars) > 0: jvars = "%s," % jvars jvars = ("%s%s" % (jvars, string.join(vVars, ","))) spss_sky = "compute %s = any(1, %s)" % (i, jvars) spss.Submit(spss_sky) End program. This will make new variable in your dataset that will have 0 or 1's depending if the string(s) above match. You can then run a filter on the varname1 as ususal HtH Mike -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Anthony Bressy Sent: 28 November 2007 07:43 To: [hidden email] Subject: FILTER ON A STRING VARIABLE Hi everyone, I would like to do a filter on a string variable . I would like to select only the cases which contain a comment with a syntax. I have try to make a SELECT IF (StringVar ne "") but the filter don't run. Can you help me ? Thanks Anthony ======= 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 Anthony Bressy
Hi Anthony,
Try something like this: SELECT IF (StringVar ne " "). Exe. "Blank" in the string variable is represented like n spaces, where n is the width of the variable (you find it in the Variable View sheet). Write n spaces between the apostrophes. Or, if you wish to be more sophisticated, use this: SELECT IF length(rtrim(StringVar)) > 0. EXECUTE . It saves you the computing of blanks. HTH Jan -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Anthony Bressy Sent: Wednesday, November 28, 2007 8:43 AM To: [hidden email] Subject: FILTER ON A STRING VARIABLE Hi everyone, I would like to do a filter on a string variable . I would like to select only the cases which contain a comment with a syntax. I have try to make a SELECT IF (StringVar ne "") but the filter don't run. Can you help me ? Thanks Anthony ======= 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 _____ Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem. This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission. -.- -- ===================== 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 |
