Hi All,
I am working on the below syntax. I would like to compute the variable "plevel," which combines the scores from plevel1 to plevel8. There are 3300 cases. Each case has a score for either plevel1, or plevel2, or.plevel8. I computed these plevels from other variables, and thus, there are missing values. What kind of statement would handle the missing values? The below syntax, in its present form, only computes plevel = 1. The remaining cases are missing values. I appreciate any help. Thank you. Best, Frank do if (plevel1 = 1). compute plevel = 1. else if (plevel2 = 2). compute plevel = 2. else if (plevel3 = 3). compute plevel = 3. else if (plevel4 = 4). compute plevel = 4. else if (plevel5 = 5). compute plevel = 5. else if (plevel6 = 6). compute plevel = 6. else if (plevel7 = 7). compute plevel = 7. else if (plevel8 = 8). compute plevel = 8. end if. execute. |
fgallo, You say it combines the scores of plevel1 to 8...I don't understand
your data based on the description and the syntax. Would you mind posting some sample data, and an example of what you ideally want, which includes all possible combinations of plevel values so that list member can answer this question correctly and efficiently the first time and with useful results to you? :) hal9000 -it can only be attributed to human error........ On 4/14/07, fgallo <[hidden email]> wrote: > > Hi All, > > > > I am working on the below syntax. I would like to compute the variable > "plevel," which combines the scores from plevel1 to plevel8. There are > 3300 > cases. Each case has a score for either plevel1, or plevel2, or.plevel8. I > computed these plevels from other variables, and thus, there are missing > values. What kind of statement would handle the missing values? The below > syntax, in its present form, only computes plevel = 1. The remaining cases > are missing values. I appreciate any help. Thank you. > > > > Best, > > Frank > > > > > > do if (plevel1 = 1). > > compute plevel = 1. > > else if (plevel2 = 2). > > compute plevel = 2. > > else if (plevel3 = 3). > > compute plevel = 3. > > else if (plevel4 = 4). > > compute plevel = 4. > > else if (plevel5 = 5). > > compute plevel = 5. > > else if (plevel6 = 6). > > compute plevel = 6. > > else if (plevel7 = 7). > > compute plevel = 7. > > else if (plevel8 = 8). > > compute plevel = 8. > > end if. > > execute. > |
Hi Hal and Simon,
Thank you for responding. I apologize for the ambiguity. Here is some clarification. I would like to compute the plevel variable from plevel1 to plevel5, which have missing values (i.e., "." equals missing). Example Data Set case plevel plevel2 plevel3 plevel4 plevel5 plevel 1 1 . . . . 1 2 . . 3 . . 3 3 . . . 4 . 4 4 . . . . 5 5 5 . 2 . . . 2 Thank you. Best, Frank -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Hal 9000 Sent: Sunday, April 15, 2007 3:11 AM To: [hidden email] Subject: Re: Do if, else if statements fgallo, You say it combines the scores of plevel1 to 8...I don't understand your data based on the description and the syntax. Would you mind posting some sample data, and an example of what you ideally want, which includes all possible combinations of plevel values so that list member can answer this question correctly and efficiently the first time and with useful results to you? :) hal9000 -it can only be attributed to human error........ On 4/14/07, fgallo <[hidden email]> wrote: > > Hi All, > > > > I am working on the below syntax. I would like to compute the variable > "plevel," which combines the scores from plevel1 to plevel8. There are > 3300 > cases. Each case has a score for either plevel1, or plevel2, or.plevel8. I > computed these plevels from other variables, and thus, there are missing > values. What kind of statement would handle the missing values? The below > syntax, in its present form, only computes plevel = 1. The remaining cases > are missing values. I appreciate any help. Thank you. > > > > Best, > > Frank > > > > > > do if (plevel1 = 1). > > compute plevel = 1. > > else if (plevel2 = 2). > > compute plevel = 2. > > else if (plevel3 = 3). > > compute plevel = 3. > > else if (plevel4 = 4). > > compute plevel = 4. > > else if (plevel5 = 5). > > compute plevel = 5. > > else if (plevel6 = 6). > > compute plevel = 6. > > else if (plevel7 = 7). > > compute plevel = 7. > > else if (plevel8 = 8). > > compute plevel = 8. > > end if. > > execute. > |
In reply to this post by Hal 9000
Hi Hal, Simon, and Richard,
Thank you for your input. After hearing from you, I created the below syntax, which works well. Thank you. Best, Frank do if nvalid(plevel1 = 1). compute plevel = 1. else if nvalid(plevel2 = 2). compute plevel = 2. else if nvalid(plevel3 = 3). compute plevel = 3. else if nvalid(plevel4 = 4). compute plevel = 4. else if nvalid(plevel5 = 5). compute plevel = 5. else if nvalid(plevel6 = 6). compute plevel = 6. else if nvalid(plevel7 = 7). compute plevel = 7. else if nvalid(plevel8 = 8). compute plevel = 8. end if. execute. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Hal 9000 Sent: Sunday, April 15, 2007 3:11 AM To: [hidden email] Subject: Re: Do if, else if statements fgallo, You say it combines the scores of plevel1 to 8...I don't understand your data based on the description and the syntax. Would you mind posting some sample data, and an example of what you ideally want, which includes all possible combinations of plevel values so that list member can answer this question correctly and efficiently the first time and with useful results to you? :) hal9000 -it can only be attributed to human error........ On 4/14/07, fgallo <[hidden email]> wrote: > > Hi All, > > > > I am working on the below syntax. I would like to compute the variable > "plevel," which combines the scores from plevel1 to plevel8. There are > 3300 > cases. Each case has a score for either plevel1, or plevel2, or.plevel8. I > computed these plevels from other variables, and thus, there are missing > values. What kind of statement would handle the missing values? The below > syntax, in its present form, only computes plevel = 1. The remaining cases > are missing values. I appreciate any help. Thank you. > > > > Best, > > Frank > > > > > > do if (plevel1 = 1). > > compute plevel = 1. > > else if (plevel2 = 2). > > compute plevel = 2. > > else if (plevel3 = 3). > > compute plevel = 3. > > else if (plevel4 = 4). > > compute plevel = 4. > > else if (plevel5 = 5). > > compute plevel = 5. > > else if (plevel6 = 6). > > compute plevel = 6. > > else if (plevel7 = 7). > > compute plevel = 7. > > else if (plevel8 = 8). > > compute plevel = 8. > > end if. > > execute. > |
In reply to this post by fgallo
Hi All,
I have a follow-up question to my below syntax. I now have two variables: plevel that may equal 1 to 8 and slevel that may equal 1 to 5. There are 3,300 cases. I want to compute the frequencies of the different combinations of plevel and slevel. Here is some sample data: case plevel slevel 1 3 1 2 8 5 3 3 2 4 6 3 5 7 4 etc.. I am thinking of computing a decimal and then checking the frequency of combinations. I do not know how to do it for this example. But, is this the best way? What do you suggest? How could I accomplish my goal? Thank you. Best, Frank -----Original Message----- From: fgallo [mailto:[hidden email]] Sent: Sunday, April 15, 2007 8:32 AM To: '[hidden email]' Subject: RE: Do if, else if statements Hi Hal, Simon, and Richard, Thank you for your input. After hearing from you, I created the below syntax, which works well. Thank you. Best, Frank do if nvalid(plevel1 = 1). compute plevel = 1. else if nvalid(plevel2 = 2). compute plevel = 2. else if nvalid(plevel3 = 3). compute plevel = 3. else if nvalid(plevel4 = 4). compute plevel = 4. else if nvalid(plevel5 = 5). compute plevel = 5. else if nvalid(plevel6 = 6). compute plevel = 6. else if nvalid(plevel7 = 7). compute plevel = 7. else if nvalid(plevel8 = 8). compute plevel = 8. end if. execute. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Hal 9000 Sent: Sunday, April 15, 2007 3:11 AM To: [hidden email] Subject: Re: Do if, else if statements fgallo, You say it combines the scores of plevel1 to 8...I don't understand your data based on the description and the syntax. Would you mind posting some sample data, and an example of what you ideally want, which includes all possible combinations of plevel values so that list member can answer this question correctly and efficiently the first time and with useful results to you? :) hal9000 -it can only be attributed to human error........ On 4/14/07, fgallo <[hidden email]> wrote: > > Hi All, > > > > I am working on the below syntax. I would like to compute the variable > "plevel," which combines the scores from plevel1 to plevel8. There are > 3300 > cases. Each case has a score for either plevel1, or plevel2, or.plevel8. I > computed these plevels from other variables, and thus, there are missing > values. What kind of statement would handle the missing values? The below > syntax, in its present form, only computes plevel = 1. The remaining cases > are missing values. I appreciate any help. Thank you. > > > > Best, > > Frank > > > > > > do if (plevel1 = 1). > > compute plevel = 1. > > else if (plevel2 = 2). > > compute plevel = 2. > > else if (plevel3 = 3). > > compute plevel = 3. > > else if (plevel4 = 4). > > compute plevel = 4. > > else if (plevel5 = 5). > > compute plevel = 5. > > else if (plevel6 = 6). > > compute plevel = 6. > > else if (plevel7 = 7). > > compute plevel = 7. > > else if (plevel8 = 8). > > compute plevel = 8. > > end if. > > execute. > |
In reply to this post by fgallo
At 08:31 AM 4/15/2007, fgallo wrote:
>I created the below syntax, which works well. > >do if nvalid(plevel1 = 1). > compute plevel = 1. >else if nvalid(plevel2 = 2). > compute plevel = 2. >else if nvalid(plevel3 = 3). > compute plevel = 3. >else if nvalid(plevel4 = 4). > compute plevel = 4. >else if nvalid(plevel5 = 5). > compute plevel = 5. >else if nvalid(plevel6 = 6). > compute plevel = 6. >else if nvalid(plevel7 = 7). > compute plevel = 7. >else if nvalid(plevel8 = 8). > compute plevel = 8. >end if. > execute. Sounds good, but if your data's as described, COMPUTE plevel=MAX(plevel1 TO plevel8) should do it, and is simpler. (See last night's post, "Re: Syntax Question: Compare 'p' and 's' variable sets") |
In reply to this post by fgallo
At 10:20 AM 4/15/2007, fgallo wrote:
>I now have two variables: plevel that may equal 1 to 8 and slevel that >may equal 1 to 5. I want to compute the frequencies of the different >combinations of plevel and slevel. Here is some sample data: CROSSTABS is meant for precisely this. |
Free forum by Nabble | Edit this page |