|
Hi,
I have an array of variables, each of which looks for errors in my data and contains a 1 if that specific error occurs. I want to reduce these variables down to one variable by using the following code: STRING ERRORS (A400). VECTOR S = SECTION1a to SECTIONU84. LOOP #I = 1 TO 75. DO IF (S(#I) = 1). COMPUTE ERRORS = CONCAT(VALUELABEL(S(#I)),'; '). END IF. END LOOP. where all the variables in SECTION1a to SECTIONU84 contain 1's and missings with the 1's given value labels describing the error in question. However, I keep getting the following error: >Error # 4328 in column 53. Text: ) >The argument of the VALUELABEL function must be a simple variable. It must >not be a constant, an expression, or a subscripted variable. >This command not executed. and am not sure what to do. Does anyone know of a solution? Cheers, Tim. ===================== 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,
You could try to replace the VECTOR/LOOP with a DO REPEAT? Not sure if a stand-in variable of a do-repeat is also called a subscripted variable. I thought the use of vectors was limited to arrays with contiguous numberings, while yours is 1a through 84, a total of 76 'units'. Cheers!! Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before you criticize someone, walk a mile in their shoes, that way when you do criticize them, you're a mile away and you have their shoes! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- On Wed, 11/11/09, Tim Pickles <[hidden email]> wrote: > From: Tim Pickles <[hidden email]> > Subject: [SPSSX-L] Array of 1's to a single variable > To: [hidden email] > Date: Wednesday, November 11, 2009, 12:40 PM > Hi, > > I have an array of variables, each of which looks for > errors in my data and > contains a 1 if that specific error occurs. I want to > reduce these > variables down to one variable by using the following > code: > > STRING ERRORS (A400). > > VECTOR S = SECTION1a to SECTIONU84. > LOOP #I = 1 TO 75. > DO IF (S(#I) = 1). > COMPUTE ERRORS = CONCAT(VALUELABEL(S(#I)),'; > '). > END IF. > END LOOP. > > where all the variables in SECTION1a to SECTIONU84 contain > 1's and missings > with the 1's given value labels describing the error in > question. > > However, I keep getting the following error: > > >Error # 4328 in column 53. Text: ) > >The argument of the VALUELABEL function must be a > simple variable. It must > >not be a constant, an expression, or a subscripted > variable. > >This command not executed. > > and am not sure what to do. Does anyone know of a > solution? > > Cheers, > Tim. > > ===================== > 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 Tim Pickles
Tim,
You are using concat incorrectly. Briefly, but you should read the documentation for the concat function, concat combines values in a single command. So, you could say COMPUTE ERRORS = CONCAT(VALUELABEL(Section1a),'; ',VALUELABEL(Section2)). You can do what you want in a single concat statement--in theory. However, I wonder if there is a limit to the length of the command line, which would approach 4300 characters in length if strung out end to end. I don't know how spss' command processor works in detail. Maybe somebody else knows about command lines and how they are processed. But, you could it as you describe, using a loop, or, as Albert-Jan suggested, using do repeat. There is a key operation you need to do, which is to trim errors before concantenating. So, using loop. STRING ERRORS (A400). VECTOR S = SECTION1a to SECTIONU84. LOOP #I = 1 TO 75. DO IF (S(#I) = 1). COMPUTE ERRORS = CONCAT(rtrim(errors),' ',rtrim(VALUELABEL(S(#I))),';'). END IF. END LOOP. Using do repeat. STRING ERRORS (A400). Do repeat S = SECTION1a to SECTIONU84. DO IF (S = 1). COMPUTE ERRORS = CONCAT(rtrim(errors),' ',rtrim(VALUELABEL(S)),';'). END IF. End repeat. Notice that I also trimmed the value returned by the valuelabels function because I don't know how the length of the underlying value labels vector is determined. Also, notice that I changed the delimiter from '; ' to ';' because the trim operation will remove the space character following the semicolon. I added the space character back in following the trimmed errors. Bear in mind that all this is untested. Gene Maguin >>I have an array of variables, each of which looks for errors in my data and contains a 1 if that specific error occurs. I want to reduce these variables down to one variable by using the following code: STRING ERRORS (A400). VECTOR S = SECTION1a to SECTIONU84. LOOP #I = 1 TO 75. DO IF (S(#I) = 1). COMPUTE ERRORS = CONCAT(VALUELABEL(S(#I)),'; '). END IF. END LOOP. where all the variables in SECTION1a to SECTIONU84 contain 1's and missings with the 1's given value labels describing the error in question. However, I keep getting the following error: >Error # 4328 in column 53. Text: ) >The argument of the VALUELABEL function must be a simple variable. It must >not be a constant, an expression, or a subscripted variable. >This command not executed. and am not sure what to do. Does anyone know of a solution? Cheers, Tim. ===================== 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 |
| Free forum by Nabble | Edit this page |
