|
Hi,
I have two variables; RaceEth1 and RaceEth2 from a survey where participants were asked to circle their race/ethnicity. However, some participants circled more than one category (e.g. HIspanic and Pacific Islander) so entered the data as two different variables. RaceEth2=0 if they only circled one category. It turns out only 4% of participants chose two categories and so I want to create a new variable (or I could recode RaceEth1) such that participants who marked two categories are coded as 6 in the new variable. I wrote the below code and forgot about the missing so got '0' in the new variable Race_Eth when there was a '99' (missing) for RaceEth1. I added the line for missing but the new variable Race_Eth still shows a '0' instead of '99'. Thanks for any help, Jan Compute Race_Eth=0. If (RaceEth1=99) Race_Eth=99. If (RaceEth2=0) Race_Eth=RaceEth1. If (RaceEth2>0) Race_Eth=6. Variable labels Race_Eth 'Survey race/ethnicity'. Freq Race_Eth. Execute. ===================== 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 |
|
Jan
Looks as if you've over-ridden the 99 by your 3rd
if command which should read:
If (RaceEth2>0) and (raceth2 ne 99) Race_Eth=6.
If is an expensive command to run (especially on
vary large data sets) as it passes through the data for each if.
You can create a new variable by:
compute race_eth = race_eth1 * 10 + race_eth2
.
freq race_eth .
then use recode to get the categories you want,
combining values from both lists ( including ?? = 99) and use
missing values race_eth (99) .
|
|
It's neater if you recode ALL the values to yeild
codes from 1 to n + 99, then write value labels as necessary. Are
these your varnames or someone else's? The shorter the better for me, and
without the undescore character: too much typing.
|
| Free forum by Nabble | Edit this page |
