I must be missing something very obvious.
This was intended to be minimal syntax to see why I was not getting what I expected in a longer set of syntax. This syntax should simply list out the characters starting with the third in an input string and say whether they are equal to an "f", data list list /mystring (a100). begin data anhhfbhtfvbknkngfhmknljgbhtufbkjnljb njnljhfhvnlbhgvhblbfgnbhfffgjfdlukn;kvctruyugcuhbkjc jhghfchbhjgctlhgfvvblkbugfcybhgfdjhbhjvcgycfbghgfc likljfknjhbhk nbhgvjhmbhgvnh gfvjghugfchjghvdgf hjhkhgtrcfjnjkyvgdkjhmbgfcdvhnbvygfchgbhgvtrjhfgf end data. compute LineNum=$casenum. string seq3(a3) seq4(a4) WhichChar(a1). numeric IsAn_f (f1). do repeat position=3,100. compute WhichChar = substr(mystring,position,1). compute IsAn_f= substr(mystring,position,1) eq 'f'. print table /LineNum, position, WhichChar, IsAn_f. end repeat. execute. ___________ Instead it produces this. note that "position" is not on the table for PRINT and it puts 2 of the variables. There should be Print will generate the following Variable Rec Start End Format LineNum 1 3 3 F1.0 WhichChar 1 4 4 A1 IsAn_f 1 6 6 F1.0 Print will generate the following Variable Rec Start End Format LineNum 1 100 100 F1.0 WhichChar 1 101 101 A1 IsAn_f 1 103 103 F1.0 execute. 1h 0 1 0 2n 0 2 0 3g 0 3 0 4k 0 4 0 5h 0 5 0
Art Kendall
Social Research Consultants |
Administrator
|
First DO REPEAT position = 3,100 is ODD!
Should be 3 TO 100. BUT! That gives ODD output. Reason why is position is NOT a variable, rather it seems to serve as a directive of where to place the text. I don't believe you want DO REPEAT here but rather LOOP, and certainly not DO REPEAT 3,100 ;-) Adding a PRINT on the END REPEAT will likely prompt a face palm response ;-) --- data list list /mystring (a100). begin data anhhfbhtfvbknkngfhmknljgbhtufbkjnljb njnljhfhvnlbhgvhblbfgnbhfffgjfdlukn;kvctruyugcuhbkjc jhghfchbhjgctlhgfvvblkbugfcybhgfdjhbhjvcgycfbghgfc likljfknjhbhk nbhgvjhmbhgvnh gfvjghugfchjghvdgf hjhkhgtrcfjnjkyvgdkjhmbgfcdvhnbvygfchgbhgvtrjhfgf end data. compute LineNum=$casenum. string seq3(a3) seq4(a4) WhichChar(a1). numeric IsAn_f (f1). /* swap the comments between the LOOP and DO REPEAT blocks for additional insight ;-). /*DO REPEAT position = 3 TO 100. LOOP position=3 TO 100. compute WhichChar = substr(mystring,position,1). compute IsAn_f= substr(mystring,position,1) eq 'f'. print TABLE/LineNum, position, WhichChar, IsAn_f. END LOOP. /*END REPEAT PRINT. EXECUTE. */consider */. DATA LIST LIST / x . BEGIN DATA 1 5 6 END DATA. PRINT TABLE / x 1 . EXECUTE. PRINT TABLE / x 10. EXECUTE. Print will generate the following Variable Rec Start End Format x 1 1 1 F1.0 EXECUTE. 1 5 6 PRINT TABLE / x 10. Print will generate the following Variable Rec Start End Format x 1 10 10 F1.0 EXECUTE. 1 5 6
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
More than one head slap is necessary.
Thanks.
Art Kendall
Social Research Consultants |
Free forum by Nabble | Edit this page |