Greetings Everyone,
I am still fairly new at using SPSS to perform a function that I normally used SAS for. I have SPSS premium ver 22. I am looking to flag to look for key string words in specific string variables. I ran into the flag function http://www.spsstools.net/Syntax/FlagOrSelectCases/FlagWhereGivenStringContainsGivenWord.sps But I am not familiar with how to apply it to my given dataset. The ideal goal is to create a variable every time the word DIABETES appears in the variable. I want a corresponding variable created that says Diabetes and then place a 1 if the term if present. This was easily done in SAS Enterprise Guide, but I am having difficulty doing the same thing in SPSS. Please let me know, Jared |
Let's not be guessing, aka, espss. 1) Given Raynald's code what's confusing to you? 2) You say "... create a variable every time the word DIABETES appears in the variable ..." Stepping over the note that the sentence is--I think the right word is "recursive", if a given string contains "diabetes five times, do you want a) ONE flag variable with a value of 1, b) ONE flag variable with a value of 5, for the five occurrences, or c) FIVE flag variables, one for each time the word occurs and each having a value 1. For a given string that does not contain the word diabetes a), b), and c) the flags would all equal 0.
Gene Maguin -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of egotisticalepi Sent: Thursday, July 23, 2015 3:10 PM To: [hidden email] Subject: SAS To SPSS Greetings Everyone, I am still fairly new at using SPSS to perform a function that I normally used SAS for. I have SPSS premium ver 22. I am looking to flag to look for key string words in specific string variables. I ran into the flag function http://www.spsstools.net/Syntax/FlagOrSelectCases/FlagWhereGivenStringContainsGivenWord.sps But I am not familiar with how to apply it to my given dataset. The ideal goal is to create a variable every time the word DIABETES appears in the variable. I want a corresponding variable created that says Diabetes and then place a 1 if the term if present. This was easily done in SAS Enterprise Guide, but I am having difficulty doing the same thing in SPSS. Please let me know, Jared -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SAS-To-SPSS-tp5730267.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 |
In reply to this post by egotisticalepi
compute FlagVar=char.index(varname, "DIABETES")>0.
If you want to ignore case: compute FlagVar=char.index(lower(varname), "diabetes")>0. Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] From: egotisticalepi <[hidden email]> To: [hidden email] Date: 07/23/2015 02:11 PM Subject: SAS To SPSS Sent by: "SPSSX(r) Discussion" <[hidden email]> Greetings Everyone, I am still fairly new at using SPSS to perform a function that I normally used SAS for. I have SPSS premium ver 22. I am looking to flag to look for key string words in specific string variables. I ran into the flag function http://www.spsstools.net/Syntax/FlagOrSelectCases/FlagWhereGivenStringContainsGivenWord.sps But I am not familiar with how to apply it to my given dataset. The ideal goal is to create a variable every time the word DIABETES appears in the variable. I want a corresponding variable created that says Diabetes and then place a 1 if the term if present. This was easily done in SAS Enterprise Guide, but I am having difficulty doing the same thing in SPSS. Please let me know, Jared -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SAS-To-SPSS-tp5730267.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 |
In reply to this post by egotisticalepi
compute hasdiabetes = char.index(lower(s),
"diabetes") > 0.
where s is is the string variable you want to scan. This assumes you want to match ignoring case. If you need to worry about word boundaries, a different approach would be needed, but this will match any string where those letters appear. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: egotisticalepi <[hidden email]> To: [hidden email] Date: 07/23/2015 01:11 PM Subject: [SPSSX-L] SAS To SPSS Sent by: "SPSSX(r) Discussion" <[hidden email]> Greetings Everyone, I am still fairly new at using SPSS to perform a function that I normally used SAS for. I have SPSS premium ver 22. I am looking to flag to look for key string words in specific string variables. I ran into the flag function http://www.spsstools.net/Syntax/FlagOrSelectCases/FlagWhereGivenStringContainsGivenWord.sps But I am not familiar with how to apply it to my given dataset. The ideal goal is to create a variable every time the word DIABETES appears in the variable. I want a corresponding variable created that says Diabetes and then place a 1 if the term if present. This was easily done in SAS Enterprise Guide, but I am having difficulty doing the same thing in SPSS. Please let me know, Jared -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SAS-To-SPSS-tp5730267.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 |
Greetings All,
Thanks for these options. Where precisely do I enter this line of code. I placed it in output and tried to run it, but I think I have failed. Any additional assistance would be of great help. Apologies! I am still getting the hang of this. |
File>New>Syntax
Enter and run the command in the syntax window. Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] From: egotisticalepi <[hidden email]> To: [hidden email] Date: 07/23/2015 04:02 PM Subject: Re: SAS To SPSS Sent by: "SPSSX(r) Discussion" <[hidden email]> Greetings All, Thanks for these options. Where precisely do I enter this line of code. I placed it in output and tried to run it, but I think I have failed. Any additional assistance would be of great help. Apologies! I am still getting the hang of this. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SAS-To-SPSS-tp5730267p5730271.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 |
Greetings All,
I appreciate your assistance. I was able to use this and crunch my information appropriately! Danke! Jared |
Free forum by Nabble | Edit this page |