It looks like I haven't tested !DEFINE with DO REPEAT, even though I remember doing that. There aren't any tests that exercise them together.
On Thu, Jan 16, 2025 at 12:30 PM Frans Houweling <fhouwel...@email.it> wrote: > > I'm afraid DO REPEAT does not work well inside DEFINE. Here is a workaround: > > define !subscore3 (!pos !tokens(1)/!pos !enclose('(',')')/!pos !tokens(1)) > !LET !limits = !2 > !DO !ssc = 1 !TO 19 > !LET !limit = !HEAD(!limits) > !LET !limits = !TAIL(!limits) > if (!1 ge !limit) !3 = !ssc. > !DOEND > !enddefine. > > I put an exclamation point before subscore3 to distinguish it from your > original. > > DATA LIST FREE /ctraw. > BEGIN DATA > 63 > END DATA. > !subscore33 ctraw (0 10 14 18 22 26 30 34 38 42 46 49 52 55 58 62 65 100 100) > ct. > LIST. > > Data List > +-----+-----+ > |ctraw| ct | > +-----+-----+ > |63.00|16.00| > +-----+-----+ > > HTH, frans > > On 1/15/25 19:33, Nanci Avitable wrote: > > I am working on a new MacBookPro, M4 chip with Sequoia. I have downloaded and > installed the PSPP version 2.0.1-2 bundle. > > I have several SPSS programs that I use to score some protocols and output > information for use in WORD via mail merge. > > These programs include Define routines. Although the information I've read > indicates that they should transfer okay, I'm running into problems. It may > be that I don't fully understand when to use periods and things like "+". > Below is a syntax portion that I've been trying to get to run. The actual > program is around 1300 lines long so I'm just focusing on a small bit. > > My interpretation from the error messages is that there is something wrong > with the "if" statement. Unless the problem is that Do Repeat cannot be used > in a macro body. > > Thanks for whatever information you can give me about using Define properly. > -- Nanci > > Data list / ctraw cutraw fatraw sltraw hstraw ltraw sctraw sdtraw straw (9f3). > Begin data. > 45 37 52 52 42 35 54 43 46 > end data. > > set Printback on. > set mprint yes. > > define subscore3 (!pos !tokens(1)/!pos !enclose('(',')')/!pos !tokens(1)) > do repeat ssc = 1 to 19/limit = !2. > if (!1 ge limit) !3 = ssc. > end repeat. > !enddefine. > > do repeat ssc = 1 to 19 / limit = 0 10 14 18 22 26 30 34 38 42 46 49 52 55 58 > 62 65 100 100. > if(ctraw ge limit)ct = ssc. > end repeat. > > /Users/nanciavitable/Cloud-drive/Private > Practice/Scoring&Report/ABASIII/ABASmacro.sps:7.1-7.78: error: DO REPEAT: In > syntax expanded from `subscore3 ctraw (0 10 14 18 22 26 30 34 38 42 46 49 52 > 55 58...': Syntax error expecting END REPEAT. > 7 | subscore3 ctraw (0 10 14 18 22 26 30 34 38 42 46 49 52 55 58 62 65 > 100 100) ct. > | > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > /Users/nanciavitable/Cloud-drive/Private > Practice/Scoring&Report/ABASIII/ABASmacro.sps:7.1-7.78: error: END REPEAT: In > syntax expanded from `subscore3 ctraw (0 10 14 18 22 26 30 34 38 42 46 49 52 > 55 58...': No matching DO REPEAT. > 7 | subscore3 ctraw (0 10 14 18 22 26 30 34 38 42 46 49 52 55 58 62 65 > 100 100) ct. > | > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > subscore3 ctraw (0 10 14 18 22 26 30 34 38 42 46 49 52 55 58 62 65 100 100) > ct. > > >