Quantcast

Odd Vector Behavior

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Odd Vector Behavior

Stan Gorodenski
I have the following syntax:


GET FILE 'SUBDIR\Referencefile'.
select if casenum le 10.
string title (a403) / journal (a201) / author (a302).
string allvars (a1069).
string line1 (a80) / line2 to line14 (a70) / space (a10).

compute title=concat(ltrim(rtrim(title1)),' ',ltrim(rtrim(title2)),'
',ltrim(rtrim(title3)),' ',ltrim(rtrim(title4))).
compute author=concat(ltrim(rtrim(author1)),' ',ltrim(rtrim(author2)),'
',ltrim(rtrim(author3))).
compute journal=concat(ltrim(rtrim(journal1)),' ',ltrim(rtrim(journal2))).
compute allvars=concat(rtrim(author),', ',rtrim(year),'
',rtrim(month),', "',rtrim(title),'", ',
                        rtrim(citation),', ',rtrim(string(casenum,f5))).

compute line1 = substr(allvars,1,80).
vector line = line2 to line14.
loop #i=2 to 14.
     compute line(#i) = substr(allvars,((10+#i*70+1)-70),70).
end loop.


When I run this program I get the following warning mesage for each case:
Warning # 520
The subscript of a string vector is missing, out of range, or not an
integer.
The result will be a reference to a string of length 0.
Command line: 346  Current case: 3  Current splitfile group: 1


The only way this program will work is if I change the string command from
string line2 to line14 (a70)
to
string line2 to line15 (a70)

and change the vector command from
vector line = line2 to line14.
to
vector line = line2 to line15.

Even though the loop goes from 2 to 14 and never goes to 15,  I need to
create another variable, line15, that I will never use and declare it in
the vector command. Can anyone explain this? I have rebooted the
computer with the same result. I also thought that the variable, line1,
might somehow be confusing the vector command and so I changed the name
of this variable but I still got the same result.
Stan

=====================
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odd Vector Behavior

Jon Peck
Your loop is starting with the second element of the vector line, which is line3.  The vector declaration covers line2, line3, ... line14, which is 13 variables, so line(14) is out of range,

On Sat, May 13, 2017 at 6:26 PM, Stan Gorodenski <[hidden email]> wrote:
I have the following syntax:


GET FILE 'SUBDIR\Referencefile'.
select if casenum le 10.
string title (a403) / journal (a201) / author (a302).
string allvars (a1069).
string line1 (a80) / line2 to line14 (a70) / space (a10).

compute title=concat(ltrim(rtrim(title1)),' ',ltrim(rtrim(title2)),' ',ltrim(rtrim(title3)),' ',ltrim(rtrim(title4))).
compute author=concat(ltrim(rtrim(author1)),' ',ltrim(rtrim(author2)),' ',ltrim(rtrim(author3))).
compute journal=concat(ltrim(rtrim(journal1)),' ',ltrim(rtrim(journal2))).
compute allvars=concat(rtrim(author),', ',rtrim(year),' ',rtrim(month),', "',rtrim(title),'", ',
                       rtrim(citation),', ',rtrim(string(casenum,f5))).

compute line1 = substr(allvars,1,80).
vector line = line2 to line14.
loop #i=2 to 14.
    compute line(#i) = substr(allvars,((10+#i*70+1)-70),70).
end loop.


When I run this program I get the following warning mesage for each case:
Warning # 520
The subscript of a string vector is missing, out of range, or not an integer.
The result will be a reference to a string of length 0.
Command line: 346  Current case: 3  Current splitfile group: 1


The only way this program will work is if I change the string command from
string line2 to line14 (a70)
to
string line2 to line15 (a70)

and change the vector command from
vector line = line2 to line14.
to
vector line = line2 to line15.

Even though the loop goes from 2 to 14 and never goes to 15,  I need to create another variable, line15, that I will never use and declare it in the vector command. Can anyone explain this? I have rebooted the computer with the same result. I also thought that the variable, line1, might somehow be confusing the vector command and so I changed the name of this variable but I still got the same result.
Stan

=====================
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



--
Jon K Peck
[hidden email]

===================== 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odd Vector Behavior

Stan Gorodenski
I'm afraid I don't understand it. The loop goes from #i=2 to 14 which is
13 loops. Thirteen vector variables are created within the loop based on
the value of #i and they all were previously defined by the vector
definition. The first vector variable created is line(2), the last is
line(14). There are thirteen vector variables and so the number of
vector variables matches the number of loops. When I define the vector to be
vector line=line2 to line14.
it is the same as
vector line=line2 line3 line3 ... line14.
When you say the vector starts with the second element of the vector
line, is the second element line3? If this is the case, then what it is
saying, to me, is that when vector variables are being created within a
loop, the numeric values that define the number of loops is linked to a
position in the vector declaration. Is this true? If it is it seems odd
to me because why would the number of iterations in a loop have to
correspond to the number of vector variables being defined when no new
vector variables are being created that were not defined in the vector
statement?
Stan

On 5/13/2017 8:17 PM, Jon Peck wrote:

> Your loop is starting with the second element of the vector line,
> which is line3.  The vector declaration covers line2, line3, ...
> line14, which is 13 variables, so line(14) is out of range,
>
> On Sat, May 13, 2017 at 6:26 PM, Stan Gorodenski
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     I have the following syntax:
>
>
>     GET FILE 'SUBDIR\Referencefile'.
>     select if casenum le 10.
>     string title (a403) / journal (a201) / author (a302).
>     string allvars (a1069).
>     string line1 (a80) / line2 to line14 (a70) / space (a10).
>
>     compute title=concat(ltrim(rtrim(title1)),'
>     ',ltrim(rtrim(title2)),' ',ltrim(rtrim(title3)),'
>     ',ltrim(rtrim(title4))).
>     compute author=concat(ltrim(rtrim(author1)),'
>     ',ltrim(rtrim(author2)),' ',ltrim(rtrim(author3))).
>     compute journal=concat(ltrim(rtrim(journal1)),'
>     ',ltrim(rtrim(journal2))).
>     compute allvars=concat(rtrim(author),', ',rtrim(year),'
>     ',rtrim(month),', "',rtrim(title),'", ',
>                            rtrim(citation),',
>     ',rtrim(string(casenum,f5))).
>
>     compute line1 = substr(allvars,1,80).
>     vector line = line2 to line14.
>     loop #i=2 to 14.
>         compute line(#i) = substr(allvars,((10+#i*70+1)-70),70).
>     end loop.
>
>
>     When I run this program I get the following warning mesage for
>     each case:
>     Warning # 520
>     The subscript of a string vector is missing, out of range, or not
>     an integer.
>     The result will be a reference to a string of length 0.
>     Command line: 346  Current case: 3  Current splitfile group: 1
>
>
>     The only way this program will work is if I change the string
>     command from
>     string line2 to line14 (a70)
>     to
>     string line2 to line15 (a70)
>
>     and change the vector command from
>     vector line = line2 to line14.
>     to
>     vector line = line2 to line15.
>
>     Even though the loop goes from 2 to 14 and never goes to 15,  I
>     need to create another variable, line15, that I will never use and
>     declare it in the vector command. Can anyone explain this? I have
>     rebooted the computer with the same result. I also thought that
>     the variable, line1, might somehow be confusing the vector command
>     and so I changed the name of this variable but I still got the
>     same result.
>     Stan
>
>     =====================
>     To manage your subscription to SPSSX-L, send a message to
>     [hidden email] <mailto:[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
>
>
>
>
> --
> Jon K Peck
> [hidden email] <mailto:[hidden email]>
>
> ===================== To manage your subscription to SPSSX-L, send a
> message to [hidden email]
> <mailto:[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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odd Vector Behavior

Kirill Orlov
Stan,

Your mistake is that you may be confusing in perception the inde[ in the var name (e.g. "line2") with its index (position) in the vector (e.g. "line(2)")
Use
vector line = line1 to line14.
instead of
vector line = line2 to line14.
Note that all string vars from line1 to line 2 must be of the same width, so create line1 of width 70, too, not of width 80.



14.05.2017 7:31, Stan Gorodenski пишет:
I'm afraid I don't understand it. The loop goes from #i=2 to 14 which is 13 loops. Thirteen vector variables are created within the loop based on the value of #i and they all were previously defined by the vector definition. The first vector variable created is line(2), the last is line(14). There are thirteen vector variables and so the number of vector variables matches the number of loops. When I define the vector to be
vector line=line2 to line14.
it is the same as
vector line=line2 line3 line3 ... line14.
When you say the vector starts with the second element of the vector line, is the second element line3? If this is the case, then what it is saying, to me, is that when vector variables are being created within a loop, the numeric values that define the number of loops is linked to a position in the vector declaration. Is this true? If it is it seems odd to me because why would the number of iterations in a loop have to correspond to the number of vector variables being defined when no new vector variables are being created that were not defined in the vector statement?
Stan

On 5/13/2017 8:17 PM, Jon Peck wrote:
Your loop is starting with the second element of the vector line, which is line3.  The vector declaration covers line2, line3, ... line14, which is 13 variables, so line(14) is out of range,

On Sat, May 13, 2017 at 6:26 PM, Stan Gorodenski <[hidden email] [hidden email]> wrote:

    I have the following syntax:


    GET FILE 'SUBDIR\Referencefile'.
    select if casenum le 10.
    string title (a403) / journal (a201) / author (a302).
    string allvars (a1069).
    string line1 (a80) / line2 to line14 (a70) / space (a10).

    compute title=concat(ltrim(rtrim(title1)),'
    ',ltrim(rtrim(title2)),' ',ltrim(rtrim(title3)),'
    ',ltrim(rtrim(title4))).
    compute author=concat(ltrim(rtrim(author1)),'
    ',ltrim(rtrim(author2)),' ',ltrim(rtrim(author3))).
    compute journal=concat(ltrim(rtrim(journal1)),'
    ',ltrim(rtrim(journal2))).
    compute allvars=concat(rtrim(author),', ',rtrim(year),'
    ',rtrim(month),', "',rtrim(title),'", ',
                           rtrim(citation),',
    ',rtrim(string(casenum,f5))).

    compute line1 = substr(allvars,1,80).
    vector line = line2 to line14.
    loop #i=2 to 14.
        compute line(#i) = substr(allvars,((10+#i*70+1)-70),70).
    end loop.


    When I run this program I get the following warning mesage for
    each case:
    Warning # 520
    The subscript of a string vector is missing, out of range, or not
    an integer.
    The result will be a reference to a string of length 0.
    Command line: 346  Current case: 3  Current splitfile group: 1


    The only way this program will work is if I change the string
    command from
    string line2 to line14 (a70)
    to
    string line2 to line15 (a70)

    and change the vector command from
    vector line = line2 to line14.
    to
    vector line = line2 to line15.

    Even though the loop goes from 2 to 14 and never goes to 15,  I
    need to create another variable, line15, that I will never use and
    declare it in the vector command. Can anyone explain this? I have
    rebooted the computer with the same result. I also thought that
    the variable, line1, might somehow be confusing the vector command
    and so I changed the name of this variable but I still got the
    same result.
    Stan

    =====================
    To manage your subscription to SPSSX-L, send a message to
    [hidden email] [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




-- 
Jon K Peck
[hidden email] [hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] [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



===================== 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odd Vector Behavior

Kirill Orlov
Stan,

Your mistake is that you may be confusing in perception the index in the var name (e.g. "line2") with its index (position) in the vector (e.g. "line(2)")
Use
vector line = line1 to line14.
instead of
vector line = line2 to line14.
Note that all string vars from line1 to line14 must be of the same width, so create line1 of width 70, too, not of width 80.


14.05.2017 8:21, Kirill Orlov пишет:
Stan,

Your mistake is that you may be confusing in perception the inde[ in the var name (e.g. "line2") with its index (position) in the vector (e.g. "line(2)")
Use
vector line = line1 to line14.
instead of
vector line = line2 to line14.
Note that all string vars from line1 to line 2 must be of the same width, so create line1 of width 70, too, not of width 80.



14.05.2017 7:31, Stan Gorodenski пишет:
I'm afraid I don't understand it. The loop goes from #i=2 to 14 which is 13 loops. Thirteen vector variables are created within the loop based on the value of #i and they all were previously defined by the vector definition. The first vector variable created is line(2), the last is line(14). There are thirteen vector variables and so the number of vector variables matches the number of loops. When I define the vector to be
vector line=line2 to line14.
it is the same as
vector line=line2 line3 line3 ... line14.
When you say the vector starts with the second element of the vector line, is the second element line3? If this is the case, then what it is saying, to me, is that when vector variables are being created within a loop, the numeric values that define the number of loops is linked to a position in the vector declaration. Is this true? If it is it seems odd to me because why would the number of iterations in a loop have to correspond to the number of vector variables being defined when no new vector variables are being created that were not defined in the vector statement?
Stan

On 5/13/2017 8:17 PM, Jon Peck wrote:
Your loop is starting with the second element of the vector line, which is line3.  The vector declaration covers line2, line3, ... line14, which is 13 variables, so line(14) is out of range,

On Sat, May 13, 2017 at 6:26 PM, Stan Gorodenski <[hidden email] [hidden email]> wrote:

    I have the following syntax:


    GET FILE 'SUBDIR\Referencefile'.
    select if casenum le 10.
    string title (a403) / journal (a201) / author (a302).
    string allvars (a1069).
    string line1 (a80) / line2 to line14 (a70) / space (a10).

    compute title=concat(ltrim(rtrim(title1)),'
    ',ltrim(rtrim(title2)),' ',ltrim(rtrim(title3)),'
    ',ltrim(rtrim(title4))).
    compute author=concat(ltrim(rtrim(author1)),'
    ',ltrim(rtrim(author2)),' ',ltrim(rtrim(author3))).
    compute journal=concat(ltrim(rtrim(journal1)),'
    ',ltrim(rtrim(journal2))).
    compute allvars=concat(rtrim(author),', ',rtrim(year),'
    ',rtrim(month),', "',rtrim(title),'", ',
                           rtrim(citation),',
    ',rtrim(string(casenum,f5))).

    compute line1 = substr(allvars,1,80).
    vector line = line2 to line14.
    loop #i=2 to 14.
        compute line(#i) = substr(allvars,((10+#i*70+1)-70),70).
    end loop.


    When I run this program I get the following warning mesage for
    each case:
    Warning # 520
    The subscript of a string vector is missing, out of range, or not
    an integer.
    The result will be a reference to a string of length 0.
    Command line: 346  Current case: 3  Current splitfile group: 1


    The only way this program will work is if I change the string
    command from
    string line2 to line14 (a70)
    to
    string line2 to line15 (a70)

    and change the vector command from
    vector line = line2 to line14.
    to
    vector line = line2 to line15.

    Even though the loop goes from 2 to 14 and never goes to 15,  I
    need to create another variable, line15, that I will never use and
    declare it in the vector command. Can anyone explain this? I have
    rebooted the computer with the same result. I also thought that
    the variable, line1, might somehow be confusing the vector command
    and so I changed the name of this variable but I still got the
    same result.
    Stan

    =====================
    To manage your subscription to SPSSX-L, send a message to
    [hidden email] [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




-- 
Jon K Peck
[hidden email] [hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] [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





===================== 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odd Vector Behavior

Rich Ulrich
In reply to this post by Stan Gorodenski

No, the first element of line() is line2 when you say

Vector line= line1 to line14. 


Since you set up the vector as line2 to line14, you have created the

(undesirable) situation were the item referenced by line(1) - its first

element - is line2.  Don't do that unless you want to plague yourself of

some later maintainer with confusion and error.  If you /have/ to  do that,

then use plenty of Comments to leave the clue.


--

Rich Ulrich


From: SPSSX(r) Discussion <[hidden email]> on behalf of Stan Gorodenski <[hidden email]>
Sent: Sunday, May 14, 2017 12:31:42 AM
To: [hidden email]
Subject: Re: Odd Vector Behavior
 
I'm afraid I don't understand it. The loop goes from #i=2 to 14 which is
13 loops. Thirteen vector variables are created within the loop based on
the value of #i and they all were previously defined by the vector
definition. The first vector variable created is line(2), the last is
line(14). There are thirteen vector variables and so the number of
vector variables matches the number of loops. When I define the vector to be
vector line=line2 to line14.
it is the same as
vector line=line2 line3 line3 ... line14.
When you say the vector starts with the second element of the vector
line, is the second element line3? If this is the case, then what it is
saying, to me, is that when vector variables are being created within a
loop, the numeric values that define the number of loops is linked to a
position in the vector declaration. Is this true? If it is it seems odd
to me because why would the number of iterations in a loop have to
correspond to the number of vector variables being defined when no new
vector variables are being created that were not defined in the vector
statement?
Stan

On 5/13/2017 8:17 PM, Jon Peck wrote:
> Your loop is starting with the second element of the vector line,
> which is line3.  The vector declaration covers line2, line3, ...
> line14, which is 13 variables, so line(14) is out of range,
>
> On Sat, May 13, 2017 at 6:26 PM, Stan Gorodenski
> <[hidden email] <[hidden email]>> wrote:
>
>     I have the following syntax:
>
>
>     GET FILE 'SUBDIR\Referencefile'.
>     select if casenum le 10.
>     string title (a403) / journal (a201) / author (a302).
>     string allvars (a1069).
>     string line1 (a80) / line2 to line14 (a70) / space (a10).
>
>     compute title=concat(ltrim(rtrim(title1)),'
>     ',ltrim(rtrim(title2)),' ',ltrim(rtrim(title3)),'
>     ',ltrim(rtrim(title4))).
>     compute author=concat(ltrim(rtrim(author1)),'
>     ',ltrim(rtrim(author2)),' ',ltrim(rtrim(author3))).
>     compute journal=concat(ltrim(rtrim(journal1)),'
>     ',ltrim(rtrim(journal2))).
>     compute allvars=concat(rtrim(author),', ',rtrim(year),'
>     ',rtrim(month),', "',rtrim(title),'", ',
>                            rtrim(citation),',
>     ',rtrim(string(casenum,f5))).
>
>     compute line1 = substr(allvars,1,80).
>     vector line = line2 to line14.
>     loop #i=2 to 14.
>         compute line(#i) = substr(allvars,((10+#i*70+1)-70),70).
>     end loop.
>
>
>     When I run this program I get the following warning mesage for
>     each case:
>     Warning # 520
>     The subscript of a string vector is missing, out of range, or not
>     an integer.
>     The result will be a reference to a string of length 0.
>     Command line: 346  Current case: 3  Current splitfile group: 1
>
>
>     The only way this program will work is if I change the string
>     command from
>     string line2 to line14 (a70)
>     to
>     string line2 to line15 (a70)
>
>     and change the vector command from
>     vector line = line2 to line14.
>     to
>     vector line = line2 to line15.
>
>     Even though the loop goes from 2 to 14 and never goes to 15,  I
>     need to create another variable, line15, that I will never use and
>     declare it in the vector command. Can anyone explain this? I have
>     rebooted the computer with the same result. I also thought that
>     the variable, line1, might somehow be confusing the vector command
>     and so I changed the name of this variable but I still got the
>     same result.
>     Stan
>
>     =====================
>     To manage your subscription to SPSSX-L, send a message to
>     [hidden email] <[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
>
>
>
>
> --
> Jon K Peck
> [hidden email] <[hidden email]>
>
> ===================== To manage your subscription to SPSSX-L, send a
> message to [hidden email]
> <[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
===================== 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odd Vector Behavior

Stan Gorodenski
Jon, Kirill, and Rich,
I think I will have to sign off for now. None of this makes sense. Maybe
when it gurgitates in my mind for a few days I will see the light. I am
retired now. I have used the pc version of spss after I retired, ver 10,
15, and now 21, a little but not anywhere near as much as when I had a
job (for the state). Then, I used it on a daily basis. My programming
was with the IBM mainframe version of spss starting with version 9 to
SPSSX. I did this for over 20 years and so the problem I am having now
is embarrassing. I was quite creative in my former job with loops and
reading odd file structures and never ran into this kind of a problem.
Maybe I just forgot, or maybe there is a difference between the way the
pc version works with regard to loops and vectors and the mainframe
version going back over 12 years ago. Could the latter be the situation?
Stan


On 5/13/2017 10:29 PM, Rich Ulrich wrote:

>
> No, the first element of line() is line2 when you say
>
> Vector line= line1 to line14.
>
>
> Since you set up the vector as line2 to line14, you have created the
>
> (undesirable) situation were the item referenced by line(1) - its first
>
> element - is line2.  Don't do that unless you want to plague yourself of
>
> some later maintainer with confusion and error.  If you /have/ to  do
> that,
>
> then use plenty of Comments to leave the clue.
>
>
> --
>
> Rich Ulrich
>
> *From:* SPSSX(r) Discussion <[hidden email]> on behalf of
> Stan Gorodenski <[hidden email]>
> *Sent:* Sunday, May 14, 2017 12:31:42 AM
> *To:* [hidden email]
> *Subject:* Re: Odd Vector Behavior
> I'm afraid I don't understand it. The loop goes from #i=2 to 14 which is
> 13 loops. Thirteen vector variables are created within the loop based on
> the value of #i and they all were previously defined by the vector
> definition. The first vector variable created is line(2), the last is
> line(14). There are thirteen vector variables and so the number of
> vector variables matches the number of loops. When I define the vector
> to be
> vector line=line2 to line14.
> it is the same as
> vector line=line2 line3 line3 ... line14.
> When you say the vector starts with the second element of the vector
> line, is the second element line3? If this is the case, then what it is
> saying, to me, is that when vector variables are being created within a
> loop, the numeric values that define the number of loops is linked to a
> position in the vector declaration. Is this true? If it is it seems odd
> to me because why would the number of iterations in a loop have to
> correspond to the number of vector variables being defined when no new
> vector variables are being created that were not defined in the vector
> statement?
> Stan
>
> On 5/13/2017 8:17 PM, Jon Peck wrote:
> > Your loop is starting with the second element of the vector line,
> > which is line3.  The vector declaration covers line2, line3, ...
> > line14, which is 13 variables, so line(14) is out of range,
> >
> > On Sat, May 13, 2017 at 6:26 PM, Stan Gorodenski
> > <[hidden email] <mailto:[hidden email]>> wrote:
> >
> >     I have the following syntax:
> >
> >
> >     GET FILE 'SUBDIR\Referencefile'.
> >     select if casenum le 10.
> >     string title (a403) / journal (a201) / author (a302).
> >     string allvars (a1069).
> >     string line1 (a80) / line2 to line14 (a70) / space (a10).
> >
> >     compute title=concat(ltrim(rtrim(title1)),'
> >     ',ltrim(rtrim(title2)),' ',ltrim(rtrim(title3)),'
> >     ',ltrim(rtrim(title4))).
> >     compute author=concat(ltrim(rtrim(author1)),'
> >     ',ltrim(rtrim(author2)),' ',ltrim(rtrim(author3))).
> >     compute journal=concat(ltrim(rtrim(journal1)),'
> >     ',ltrim(rtrim(journal2))).
> >     compute allvars=concat(rtrim(author),', ',rtrim(year),'
> >     ',rtrim(month),', "',rtrim(title),'", ',
> >                            rtrim(citation),',
> >     ',rtrim(string(casenum,f5))).
> >
> >     compute line1 = substr(allvars,1,80).
> >     vector line = line2 to line14.
> >     loop #i=2 to 14.
> >         compute line(#i) = substr(allvars,((10+#i*70+1)-70),70).
> >     end loop.
> >
> >
> >     When I run this program I get the following warning mesage for
> >     each case:
> >     Warning # 520
> >     The subscript of a string vector is missing, out of range, or not
> >     an integer.
> >     The result will be a reference to a string of length 0.
> >     Command line: 346  Current case: 3  Current splitfile group: 1
> >
> >
> >     The only way this program will work is if I change the string
> >     command from
> >     string line2 to line14 (a70)
> >     to
> >     string line2 to line15 (a70)
> >
> >     and change the vector command from
> >     vector line = line2 to line14.
> >     to
> >     vector line = line2 to line15.
> >
> >     Even though the loop goes from 2 to 14 and never goes to 15,  I
> >     need to create another variable, line15, that I will never use and
> >     declare it in the vector command. Can anyone explain this? I have
> >     rebooted the computer with the same result. I also thought that
> >     the variable, line1, might somehow be confusing the vector command
> >     and so I changed the name of this variable but I still got the
> >     same result.
> >     Stan
> >
> >     =====================
> >     To manage your subscription to SPSSX-L, send a message to
> >     [hidden email] <mailto:[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
> >
> >
> >
> >
> > --
> > Jon K Peck
> > [hidden email] <mailto:[hidden email]>
> >
> > ===================== To manage your subscription to SPSSX-L, send a
> > message to [hidden email]
> > <mailto:[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
> ===================== To manage your subscription to SPSSX-L, send a
> message to [hidden email]
> <mailto:[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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Odd Vector Behavior

Stan Gorodenski
All,
As I said, I need to gurgitate on this some more. It occurred to me that
when a vector variable is used in a compute statement in a loop, spss
has to know the variable has been declared before the compute statement
is executed. It makes more sense, from a computing efficiency point of
view, for the index number to refer to a location in the vector
declaration list rather than the system searching the list for the
variable. Is this the way it works? If it does, it make sense, in this
context, but it still does not make sense in another because when I say
compute line(#i) = substr(etc.), where #i =2
according to the logic above it would point to line3 in the vector
declaration. The declaration is
vector line = line2 to line14
If it pointed to the second location, then the system could still not
verify that line(2) is a valid vector variable in a compute statement
because the system points to line3 in the vector declaration instead of
line2.


Assuming the pc version 21 points in the way I described above, I still
wonder if it worked this way on the IBM mainframe 14 or more years ago.
I do not recall ever having this problem. Does anyone know if the IBM
mainframe version searched a vector declaration list for a specific
vector variable, or did it point to a location in the list based on the
vector variable index number? I could see spss, inc. modifying the way a
loop with a vector declaration works on a pc because of the limited
power of pc's when the program first became available for a pc. This was
when spss, inc had it, i.e., before IBM took it over.
Stan

On 5/13/2017 11:10 PM, Stan Gorodenski wrote:

> Jon, Kirill, and Rich,
> I think I will have to sign off for now. None of this makes sense.
> Maybe when it gurgitates in my mind for a few days I will see the
> light. I am retired now. I have used the pc version of spss after I
> retired, ver 10, 15, and now 21, a little but not anywhere near as
> much as when I had a job (for the state). Then, I used it on a daily
> basis. My programming was with the IBM mainframe version of spss
> starting with version 9 to SPSSX. I did this for over 20 years and so
> the problem I am having now is embarrassing. I was quite creative in
> my former job with loops and reading odd file structures and never ran
> into this kind of a problem. Maybe I just forgot, or maybe there is a
> difference between the way the pc version works with regard to loops
> and vectors and the mainframe version going back over 12 years ago.
> Could the latter be the situation?
> Stan
>
>
> On 5/13/2017 10:29 PM, Rich Ulrich wrote:
>>
>> No, the first element of line() is line2 when you say
>>
>> Vector line= line1 to line14.
>>
>>
>> Since you set up the vector as line2 to line14, you have created the
>>
>> (undesirable) situation were the item referenced by line(1) - its first
>>
>> element - is line2.  Don't do that unless you want to plague yourself of
>>
>> some later maintainer with confusion and error.  If you /have/ to  do
>> that,
>>
>> then use plenty of Comments to leave the clue.
>>
>>
>> --
>>
>> Rich Ulrich
>>
>> *From:* SPSSX(r) Discussion <[hidden email]> on behalf of
>> Stan Gorodenski <[hidden email]>
>> *Sent:* Sunday, May 14, 2017 12:31:42 AM
>> *To:* [hidden email]
>> *Subject:* Re: Odd Vector Behavior
>> I'm afraid I don't understand it. The loop goes from #i=2 to 14 which is
>> 13 loops. Thirteen vector variables are created within the loop based on
>> the value of #i and they all were previously defined by the vector
>> definition. The first vector variable created is line(2), the last is
>> line(14). There are thirteen vector variables and so the number of
>> vector variables matches the number of loops. When I define the
>> vector to be
>> vector line=line2 to line14.
>> it is the same as
>> vector line=line2 line3 line3 ... line14.
>> When you say the vector starts with the second element of the vector
>> line, is the second element line3? If this is the case, then what it is
>> saying, to me, is that when vector variables are being created within a
>> loop, the numeric values that define the number of loops is linked to a
>> position in the vector declaration. Is this true? If it is it seems odd
>> to me because why would the number of iterations in a loop have to
>> correspond to the number of vector variables being defined when no new
>> vector variables are being created that were not defined in the vector
>> statement?
>> Stan
>>
>> On 5/13/2017 8:17 PM, Jon Peck wrote:
>> > Your loop is starting with the second element of the vector line,
>> > which is line3.  The vector declaration covers line2, line3, ...
>> > line14, which is 13 variables, so line(14) is out of range,
>> >
>> > On Sat, May 13, 2017 at 6:26 PM, Stan Gorodenski
>> > <[hidden email] <mailto:[hidden email]>> wrote:
>> >
>> >     I have the following syntax:
>> >
>> >
>> >     GET FILE 'SUBDIR\Referencefile'.
>> >     select if casenum le 10.
>> >     string title (a403) / journal (a201) / author (a302).
>> >     string allvars (a1069).
>> >     string line1 (a80) / line2 to line14 (a70) / space (a10).
>> >
>> >     compute title=concat(ltrim(rtrim(title1)),'
>> >     ',ltrim(rtrim(title2)),' ',ltrim(rtrim(title3)),'
>> >     ',ltrim(rtrim(title4))).
>> >     compute author=concat(ltrim(rtrim(author1)),'
>> >     ',ltrim(rtrim(author2)),' ',ltrim(rtrim(author3))).
>> >     compute journal=concat(ltrim(rtrim(journal1)),'
>> >     ',ltrim(rtrim(journal2))).
>> >     compute allvars=concat(rtrim(author),', ',rtrim(year),'
>> >     ',rtrim(month),', "',rtrim(title),'", ',
>> >                            rtrim(citation),',
>> >     ',rtrim(string(casenum,f5))).
>> >
>> >     compute line1 = substr(allvars,1,80).
>> >     vector line = line2 to line14.
>> >     loop #i=2 to 14.
>> >         compute line(#i) = substr(allvars,((10+#i*70+1)-70),70).
>> >     end loop.
>> >
>> >
>> >     When I run this program I get the following warning mesage for
>> >     each case:
>> >     Warning # 520
>> >     The subscript of a string vector is missing, out of range, or not
>> >     an integer.
>> >     The result will be a reference to a string of length 0.
>> >     Command line: 346  Current case: 3  Current splitfile group: 1
>> >
>> >
>> >     The only way this program will work is if I change the string
>> >     command from
>> >     string line2 to line14 (a70)
>> >     to
>> >     string line2 to line15 (a70)
>> >
>> >     and change the vector command from
>> >     vector line = line2 to line14.
>> >     to
>> >     vector line = line2 to line15.
>> >
>> >     Even though the loop goes from 2 to 14 and never goes to 15,  I
>> >     need to create another variable, line15, that I will never use and
>> >     declare it in the vector command. Can anyone explain this? I have
>> >     rebooted the computer with the same result. I also thought that
>> >     the variable, line1, might somehow be confusing the vector command
>> >     and so I changed the name of this variable but I still got the
>> >     same result.
>> >     Stan
>> >
>> >     =====================
>> >     To manage your subscription to SPSSX-L, send a message to
>> >     [hidden email] <mailto:[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
>> >
>> >
>> >
>> >
>> > --
>> > Jon K Peck
>> > [hidden email] <mailto:[hidden email]>
>> >
>> > ===================== To manage your subscription to SPSSX-L, send a
>> > message to [hidden email]
>> > <mailto:[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
>> ===================== To manage your subscription to SPSSX-L, send a
>> message to [hidden email]
>> <mailto:[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
>
>

=====================
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
Loading...