Dear SPSS Listers,
I am curious to know the meaning of ##. I understand scratch variable #. But what does this double pound sign ## mean? I mostly saw this in loop program. |
Administrator
|
This post was updated on .
Riya,
Can you provide the specific code? It was most likely one of mine (or a copycat ;-). In a 'normal' SPSS context # and ## will both be treated as scratch variables. I use them mostly to indicate the level of the looping. Say if I extended the IP below to 3 levels of nesting I would likely use ### as the third level control variable. In a MATRIX program there is no such notion but I use them to indicate they are throwaways and not of any significance to the solution aside from using them as indexes to Matrices. In one case of note I am using #b, #b, #s, #t as controls within a matrix program because the paper I am working with uses them in formulas. If one used t as a variable MATRIX will render a funny error (t is short for TRANSPOSE). Yeah, there's a method to my madness. To anticipate another possible question? The + in the first column of my code is just there for readability. *--*. INPUT PROGRAM. + VECTOR V (5). + LOOP #=1 TO 10. + LOOP ##=1 TO 5. + COMPUTE V(##)=RV.UNIFORM(0,#). + END LOOP. + END CASE. + END LOOP. END FILE. END INPUT PROGRAM. FORMATS ALL (F10.5). LIST. V1 V2 V3 V4 V5 .45249 .30926 .60246 .44016 .23526 1.25511 .81698 .04934 .21896 1.50149 .28141 1.89411 1.80733 2.27208 .12114 2.80992 .73832 .58700 1.68982 2.72828 2.11903 4.97073 .34043 4.07132 3.14754 1.89735 .13130 4.45608 2.95973 .57374 2.17908 5.46643 2.35940 4.81436 .11513 4.84745 4.00656 1.53321 .82136 .49609 2.49844 8.80242 8.22399 .92355 4.65502 .12636 8.09658 1.43747 8.94884 9.07983 *Number of cases read: 10 Number of cases listed: 10 *. MATRIX . COMPUTE V=UNIFORM(10,5). LOOP #=1 TO 10. + LOOP ##=1 TO 5. + COMPUTE V(#,##) = V(#,##) * #. + END LOOP. END LOOP. PRINT V / FORMAT "F10.5" / TITLE "My little matrix that could?". DISPLAY DICTIONARY. END MATRIX. Run MATRIX procedure: My little matrix that could? .31061 .83313 .53507 .40160 .82489 1.09797 .01224 .49796 .29495 1.53192 .93221 .79862 2.10464 2.41575 .07050 3.78063 .12584 1.14645 2.38256 .90979 .35786 2.25725 4.17534 2.98023 3.04022 .46606 3.11038 .49118 5.47010 .56301 5.32857 1.56481 4.88623 3.75382 .67250 5.14244 4.05917 1.81247 3.22525 .57517 8.61627 8.67351 3.28237 1.97217 1.00668 9.17098 4.07921 4.00496 8.37930 5.46965 Variables --- Name #Rows #Columns V 10 5 # 1 1 ## 1 1 ------ END MATRIX -----
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?" |
I am currently out of the office until March 27. If you need immediate assistance, please call 812-856-5824. |
In reply to this post by Riya
At 02:17 PM 3/25/2013, Riya wrote:
>I am curious to know the meaning of ##. I understand scratch >variable #. But what does this double pound sign ## mean? I mostly >saw this in loop program. To expand on David's answer a little: The character '#' is one of those accepted in any variable name: >Variable names' first character must be a letter or one of the >characters @, #, or $. Subsequent characters can be any combination >of letters, numbers, a period (.), and non-punctuation characters. '#' has a special meaning only as the first character of a name: it specifies that the variable is a scratch variable. Otherwise, it's just a character. So, if "a#" is of a normal variable, and "#a" is the name of a scratch variable. What names you use for scratch variables, apart from the first character, is a matter of preference and aesthetics. As David notes, he often uses the names "#", "##", and "###" for look counters. The additional "#" characters are simply part of the name, and serve to distinguish different variables; using, say, "#i", "#j", and "#k", would serve the same purpose. ===================== 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 |