Greetings all. I am new to SPSS, the world of statistics and new to this forum. I am doing research in conjunction with my Masters Degree and running into a bit of a problem and looking for some help. Yes, I could ire a consultant, but view this part of the learning process, and would like to see if I cannot master this - with your help of course.....
I am looking to add: q1 and q51 q2 and q52 q3 and q53 etc.... through to q50 and q100 The new variable names currently are TOTAL1 to TOTAL50, but could be anything. Q1 to q100 exist and are consecutive TOTAL1 to TOTAL 50 exists and are consecutive I have tried: do repeat x = q1 to q50 / y = q51 to q100 / z = TOTAL1 to TOTAL50 COMPUTE z = x + y end repeat . EXECUTE But getting the following in the output: >Error # 4502 in column 11. Text: = >An equals sign appears in a variable or value list where it is not expected. >It will be ignored. >Execution of this command stops. >Error # 4508 in column 15. Text: + >Unrecognized text appears on the DO REPEAT command. It will be ignored. EXECUTE. do repeat x = q1 to q50 / y = q51 to q100 / z = TOTAL1 to TOTAL50 COMPUTE z = x + y end repeat . >Error # 4502 in column 11. Text: = >An equals sign appears in a variable or value list where it is not expected. >It will be ignored. >Execution of this command stops. >Error # 4508 in column 15. Text: + >Unrecognized text appears on the DO REPEAT command. It will be ignored. EXECUTE. Is this the best way of doing this? Can anyone spot a syntax error? |
Those damn periods - you are missing one at the end of the COMPUTE statement. Everything else looks ok to me.
|
This post was updated on .
Whoops I see you are missing a period after the DO REPEAT (and the EXECUTE) statement as well, below should work for reference:
do repeat x = q1 to q50 /y = q51 to q100 /z = TOTAL1 to TOTAL50. COMPUTE z = x + y. end repeat . EXECUTE. |
Thank you so much for your response.
I went into the journal file to try and figure out why it worked once, but not the second time... and I am still at a loss. I have tried with every combination of dot and not dot known to man.... It seems that somehow, I only had selected the first half of the DO REPEAT function in the syntax editor and that worked to create the VARIABLES. Then when I went to run it a second time, it COMPUTED the VARIABLES. Not sure what the lesson is there. Here is from the journal: do repeat a = q1 to q50 / b = q51 to q100 / c= TOTAL1 to TOTAL50 . SAVE OUTFILE='/Users/SethChancy/Downloads/SPSS/resultCCCbackup.sav' *>Warning # 141. Command name: SAVE *>DO REPEAT has no effect on this command. *>Error # 4097. Command name: SAVE *>The transformations program contains a DO REPEAT without a terminating END *>REPEAT, or the DO REPEAT loop contains a command that is not valid inside this *>type of loop. /COMPRESSED. do repeat a = q1 to q50 / b = q51 to q100 / c= TOTAL1 to TOTAL50 . *>Error # 4530. Command name: do repeat *>This command is not allowed inside the DO REPEAT/ END REPEAT facility. The *>command will be ignored. do repeat a = q1 to q50 / b = q51 to q100 / c= TOTAL1 to TOTAL50 . *>Error # 4530. Command name: do repeat *>This command is not allowed inside the DO REPEAT/ END REPEAT facility. The *>command will be ignored. compute c= a+b . end repeat. do repeat a = q1 to q50 / b = q51 to q100 / c= TOTAL1 to TOTAL50 . compute c= a+b . end repeat. FREQUENCIES VARIABLES=TOTAL1 TOTAL2 TOTAL3 TOTAL4 TOTAL5 TOTAL6 TOTAL7 TOTAL8 TOTAL9 TOTAL10 TOTAL11 TOTAL12 TOTAL13 TOTAL14 TOTAL15 TOTAL16 TOTAL17 TOTAL18 TOTAL19 TOTAL20 TOTAL21 TOTAL22 TOTAL23 TOTAL24 TOTAL25 TOTAL26 TOTAL27 TOTAL28 TOTAL29 TOTAL30 TOTAL31 TOTAL32 TOTAL33 TOTAL34 TOTAL35 TOTAL36 TOTAL37 TOTAL38 TOTAL39 TOTAL40 TOTAL41 TOTAL42 TOTAL43 TOTAL44 TOTAL45 TOTAL46 TOTAL47 TOTAL48 TOTAL49 TOTAL50 /STATISTICS=STDDEV VARIANCE MINIMUM MAXIMUM MEAN MEDIAN MODE /BARCHART FREQ /FORMAT=DVALUE /ORDER=ANALYSIS. |
It looks like basically the same problem, in that you had
SAVE OUTFILE = '/Users/SethChancy/Downloads/SPSS/resultCCCbackup.sav' do repeat a = q1 to q50 / b = q51 to q100 / c= TOTAL1 to TOTAL50 . And so SPSS did not recognize "DO REPEAT" because it was seeing if it was an argument to the SAVE command that did not have a period. If you put a line break between commands that would not happen in the future. E.g. SAVE OUTFILE = "" DO REPEAT ..... Also I thought the syntax highlighting warned you if a command did not have a period as well. |
A command can have several elements and can be on multiple lines (often for readability).
Each complete command ends with a period. Some commands need a corresponding END command. Do repeat needs an end repeat. Do if needs an end if. Loop needs an end loop. etc.
Art Kendall
Social Research Consultants |
This post was updated on .
In reply to this post by Andy W
Thanks Andy and Art for your responses. I have been able to successfully reconstruct what I did, and worked on Friday evening from the journal. Being a newbie, I confused the Output file and the Journal, and it was not until yesterday a light bulb went off, and I realized I could get out the Journal and get the command from there that succeeded.
This was the report from the Journal, so these are the things that were instructed and executed. The save file function was successful (as this was chosen from menu, not syntax). The DO REPEAT was from syntax, but it seems that when I clicked run, I used the green triangle from the menu bar (Run Selected) rather than run all. Seems that DO REPEAT had problems creating the new variables, but once they were created could COMPUTE. Thanks for everyones help! Seth |
Free forum by Nabble | Edit this page |