|
Hi,
I'm hopeful someone on the list can help me. I am working with a Bureau of Justice Statistics data file. The file is the Survey of Inmates in State and Federal Correctional Facilities, 2004. I am trying to take data from three separate variables and need to do some if function but am VERY new to this. Any help would be really appreciated. The first variable (v1056) asks respondents the state of residence at arrest. The categories include every US State, DC, Puerto Rico, Don't know, Refused, and Blank. The file includes 18185 respondents. The second variable (v1059) asks if the offense occurred in the state of residence. 14208 or 78.1% of respondents committed their crime in the state of residence. 3720 committed their offense in another state. About 250 respondents answered Don't know, Refused, or left the question blank (all separate categories). The third variable (v1060) asks the state that the offense occurred but only for those 3720 individuals that committed the offense out of their state of residence. What I would like to do is create a new variable that will give me the response from the first variable (v1056) if the answer to the second variable (v1059) is yes and give me the response to the third variable (v1060) if the response to the second variable (v1059) is no. Can anyone help me write the syntax that would allow me achieve this? I'm working on version 15 of SPSS. Thanks, Suzanne ===================== 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 |
|
Hi Suzanne,
Assumed that all variables are numeric (look in the Variable View tab), the syntax you need can have this form: IF (v1059 = _code_for_YES_) new_variable = v1056. IF (v1059 = _code_for_NO_) new_variable = v1060. EXECUTE. (Replace _code_for_YES_ and _code_for_NO_ with the appropriate numbers.) If all of them are strings, then the syntax is like: STRING new_variable (a50). IF (UPCASE(v1059) = "YES") new_variable = v1056. IF (UPCASE(v1059) = "NO") new_variable = v1060. EXECUTE. Copy the syntax in a new Syntax window, edit it if needed and run by Run -> All. Hope this helps, Jan -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Suzanne Rebecca Neusteter Sent: Tuesday, May 06, 2008 8:03 AM To: [hidden email] Subject: syntax help Hi, I'm hopeful someone on the list can help me. I am working with a Bureau of Justice Statistics data file. The file is the Survey of Inmates in State and Federal Correctional Facilities, 2004. I am trying to take data from three separate variables and need to do some if function but am VERY new to this. Any help would be really appreciated. The first variable (v1056) asks respondents the state of residence at arrest. The categories include every US State, DC, Puerto Rico, Don't know, Refused, and Blank. The file includes 18185 respondents. The second variable (v1059) asks if the offense occurred in the state of residence. 14208 or 78.1% of respondents committed their crime in the state of residence. 3720 committed their offense in another state. About 250 respondents answered Don't know, Refused, or left the question blank (all separate categories). The third variable (v1060) asks the state that the offense occurred but only for those 3720 individuals that committed the offense out of their state of residence. What I would like to do is create a new variable that will give me the response from the first variable (v1056) if the answer to the second variable (v1059) is yes and give me the response to the third variable (v1060) if the response to the second variable (v1059) is no. Can anyone help me write the syntax that would allow me achieve this? I'm working on version 15 of SPSS. Thanks, Suzanne ===================== 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. Jste si jisti, že opravdu potřebujete vytisknout tuto zprávu a/nebo její přílohy? Myslete na přírodu. 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. Are you sure that you really need a print version of this message and/or its attachments? Think about nature. -.- -- ===================== 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 |
