LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2005)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sun, 24 Jul 2005 16:04:26 -0300
Reply-To:   Hector Maletta <hmaletta@fibertel.com.ar>
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   Hector Maletta <hmaletta@fibertel.com.ar>
Subject:   Re: Need to merge two variables into one based on a condition
Comments:   To: Samantha <vettegirl5@GMAIL.COM>
In-Reply-To:   <200507241838.j6OIcd2F005490@listserv.cc.uga.edu>
Content-Type:   text/plain; charset="us-ascii"

Samantha, Let us address first your second question -- converting pay from string to numeric, and clarifying about decimal formats. You convert it into a different variable, which will be numeric, with the following syntax:

RECODE PAYA (convert) into NUMPAY. If your PAYB variable is also coded as a string, you may want to convert it also:

RECODE PAYB (CONVERT) INTO NUMDK.

Regarding formats: they only affect the visualization on screen and printed output, not the internal precision of the figure which is always kept at its maximum for SPSS, i.e. 16 decimal places. If you want the values of NUMPAY to display two decimals, add the following:

FORMAT NUMPAY (F10.2).

If you want the dollar sign included, replace (F10.2 by DOLLAR10.2). The number 10 refers to the total number of places in the visible display, including the integer and decimal parts, the decimal point and the dollar sign (and may include also the negative sign, which in your case would not be present). Thus 50000 dollars would be viewed as $50,000.00 occupying 10 spaces. If needed, e.g. if somebody earns six-figure incomes, increase it to 11 or 12 for good measure. The final 2 refers to the number of decimals. But I repeat this is only for show: the number itself is not changed by all this format manipulation.

Now for your problem with the DK/NA. Once NUMPAY is created, you may assign the corresponding values with IF statements as you seem to know how. For instance:

IF (NUMPAY=0 OR SYSMIS(NUMPAY))NUMPAY=NUMDK.

If the values of NUMDK (i.e. the values of your old PAYB) are likely to be confused with actual salaries when put into NUMPAY, i.e. confusing the code 9997 with a salary of $ 9997.00, then you may want to multiply them by 1000 or something similar. For ex.

IF (NUMPAY=0 OR SYSMIS(NUMPAY))NUMPAY=NUMDK*1000.

You may want to add some useful labels for the sake of clarity, such as:

ADD VALUE LABELS NUMPAY 9997 'Does not know' 9998 'Does not answer' 9999 'Unclear'.

Hope this helps

Hector

> -----Original Message----- > From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] > On Behalf Of Samantha > Sent: Sunday, July 24, 2005 3:39 PM > To: SPSSX-L@LISTSERV.UGA.EDU > Subject: Need to merge two variables into one based on a condition > > > I have a question in my survey that asks how much a person > earns per hour and also gives them the option to check Don't > Know (DN) or Not Applicable (NA). I didn't have control over > how the data was electronically collected and the vendor had > to split the data in two since there were two seperate > entries (ie, a written number and a check box). > > Now I am stuck with two variables: the numerical amount they > got paid (payA) and the codes for DN/NA (payB). I need to > merge these two together, but with a caveat. There are > instances where a person would put a numerical answer in payA > but would also check the NA option in payB. I need the value > in payB to be deleted if there is a value in payA and then I > need them to form one variable. > > Here's an example: > > payA payB > 1 10.50 - > 2 - 9997 > 3 6.50 9998 > > What I need is one column that would have the following > values: 1 10.50 2 9997 (could be 9997.00 if needed) 3 6.50 > > Another annoying little thing is that the payA variable was > coded as string. I know how to write the IF statement to > delete the B value if the A value is filled in, but it won't > work becaus A is string and B is numeric. When I try to > convert the string to numeric, I have problems because it > doesn't understand the decimal and just leave it out. I don't > know the FORMATS command for currency. > > I hope all this makes since. If you can solve either of my > problems it'd be MUCH apprecaited!! > > Sam >


Back to: Top of message | Previous page | Main SPSSX-L page