Error : The first word in the line is not recognized as an SPSS Statistics command.

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Error : The first word in the line is not recognized as an SPSS Statistics command.

anitha.un
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Error : The first word in the line is not recognized as an SPSS Statistics command.

David Marso
Administrator
Line 3:
"!COMPUTE "
Nix the ! .

anitha.un wrote
Hi All,

I have a requirement where i need to create variables with the pattern like Var1Sub1, Var1Sub2,Var1Sub4 , Var1Sub8, Var2Sub1, Var2Sub2, Var2Sub4 , Var2Sub8, Var3Sub1,Var3Sub2, Var3Sub4,Var3Sub8, Var3Sub9.

Below is the code i wrote :

DEFINE !myvar (nb_loop= !TOKENS(5)).
!DO !cnt=1 !TO !nb_loop
!COMPUTE !CONCAT(variable,!cnt)=!cnt.
COMPUTE !CONCAT(sub,1)=!sub1.
COMPUTE !CONCAT(!cnt,!sub1)=!var1.
COMPUTE !CONCAT(sub,2)=!sub2.
COMPUTE !CONCAT(!cnt,!sub2)=!var2.
COMPUTE !CONCAT(sub,4)=!sub4.
COMPUTE !CONCAT(!cnt,!sub4)=!var4.
COMPUTE !CONCAT(sub,8)=!sub8.
COMPUTE !CONCAT(!cnt,!sub8)=!var8.
COMPUTE !CONCAT(sub,9)=!sub9.
COMPUTE !CONCAT(!cnt,!sub9)=!var9.
!DOEND
EXECUTE.
!ENDDEFINE.

SET MPRINT ON.
!myvar nb_loop=var1 var2 var4 var8 var9.

I am getting an error : The first word in the line is not recognized as an SPSS Statistics command.
Also i tried removing " . " in the define part, but it did not work.
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?"
Reply | Threaded
Open this post in threaded view
|

Re: Error : The first word in the line is not recognized as an SPSS Statistics command.

anitha.un
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Error : The first word in the line is not recognized as an SPSS Statistics command.

David Marso
Administrator
You *NEED* to be clear on EXACTLY the syntax you wish the macro to produce.
You are pulling from !var1, !var2 !var4, !var8, !sub1, !sub2... but they have *NOT* been defined or constructed.  You are also using !DO rather than !DO !IN (You pass a list but use an iterative method rather than a list processing method!
What actual vars exist in the data file?  What vars do you with to create from what other vars?
Here's something which does what you *MIGHT* want to do but I doubt it is exactly what you want.
---
DEFINE !myvar (nb_loop= !TOKENS(5) / subx !Tokens(4)).
!DO !cnt !IN ( !nb_loop )
!DO !X !IN (!subx)
COMPUTE !CONCAT(!CNT,sub,!X)=!cnt.
!DOEND
!DOEND
EXECUTE.
!ENDDEFINE.
SET MPRINT ON.
!myvar nb_loop=var1 var2 var4 var8 var9 Subx 1 2 4 8.

Created the following.
!myvar nb_loop=var1 var2 var4 var8 var9 Subx 1 2 4 8.
 
COMPUTE var1SUB1 = var1.
COMPUTE var1SUB2 = var1.
COMPUTE var1SUB4 = var1.
COMPUTE var1SUB8 = var1.
COMPUTE var2SUB1 = var2.
COMPUTE var2SUB2 = var2.
COMPUTE var2SUB4 = var2.
COMPUTE var2SUB8 = var2.
COMPUTE var4SUB1 = var4.
COMPUTE var4SUB2 = var4.
COMPUTE var4SUB4 = var4.
COMPUTE var4SUB8 = var4.
COMPUTE var8SUB1 = var8.
COMPUTE var8SUB2 = var8.
COMPUTE var8SUB4 = var8.
COMPUTE var8SUB8 = var8.
COMPUTE var9SUB1 = var9.
COMPUTE var9SUB2 = var9.
COMPUTE var9SUB4 = var9.
COMPUTE var9SUB8 = var9.

Defining macros with specific numbers of tokens leads to non general fragile code.
What do you do when you decide you want to pass 6 vars instead of 5?  Write another macro?
Better to pass lists as something like
DEFINE !DOLIST (mylist !ENCLOSE("(",")") )
DO !I !IN (!mylist)
...
!ENDEFINE
!DOLIST mylist (var1 var2 var3 .....).


anitha.un wrote
Thank you........but i had tried that option too, it didnt work:(
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?"
Reply | Threaded
Open this post in threaded view
|

Re: Error : The first word in the line is not recognized as an SPSS Statistics command.

anitha.un
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Error : The first word in the line is not recognized as an SPSS Statistics command.

Rick Oliver-3
Rule #1:

Turn macro printing on to debug macros: SET MPRINT ON.

This will show you the syntax generated by the macro.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        "anitha.un" <[hidden email]>
To:        [hidden email]
Date:        12/02/2011 12:01 PM
Subject:        Re: Error : The first word in the line is not recognized as an              SPSS Statistics command.
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Welll...thank you sooo much. I appreciate your help on this.  And also i was
trying to do the same using arrays, below is the syntax . My output should
create variables like var1sub1, var1sub2. var1sub4, var1sub8 var1sub9,
var2sub1, var2sub2,var2sub4, var2sub8, var2sub9.

Define !myvars().
!dlist = [1 2 3 4 5].
!ilist = [1 2 4 8 9].
!ddim = len(!dlist) numeric.
!idim = len(!ilist) numeric.
    !do !i = 1 !to !ddim.
         !LET !mydvar = !CONCAT('var',!dlist(!i)).
    !do !j = 1 !to !idim.
         !LET !myivar = !CONCAT('sub',!ilist(!j)).
     !myfvar= !CONCAT(!mydvar,!myivar).
COMPUTE !myfvar=0.
!DOEND.
!DOEND.
!ENDDEFINE.
myvars.
EXECUTE.

Can you help me out to trouble shoot the error i got : The first word in the
line is not recognized as an SPSS Statistics command.This command not
executed. I am still a beginner in spss macros, so i feel there may be a
small mistake.


--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Error-The-first-word-in-the-line-is-not-recognized-as-an-SPSS-Statistics-command-tp5036280p5042683.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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

Re: Error : The first word in the line is not recognized as an SPSS Statistics command.

David Marso
Administrator
In reply to this post by anitha.un
You are making it *WAY TOO COMPLICATED*!!!
SPSS Macro knows *NOTHING* of "arrays" much or less anything of array indexes.
MACRO is simply a string parser with minimal functionality beyond !HEAD, !TAIL, !CONCAT, !SUBSTR.
It flunked *MATH* in grade school and was invented when wheels were square and computers only had ones (zero had yet to be discovered).   However in the right hands can build a primitive rocket ship from bear skins and flint shards.
You *CAN NOT* extend MACRO with constructs such as:  !ddim = len(!dlist) numeric or !ilist(!j).
It is also quite innocent of *most* things common to most "languages".
The following achieves what I infer you to be attempting.

DEFINE !myvars( DLIST !ENCLOSE("[","]")
              / ILIST !ENCLOSE("[","]") ).
!DO !ddim !IN (!DLIST) !DO !idim !IN (!ILIST)
COMPUTE !CONCAT('var',!ddim , 'sub', !idim) =0.
!DOEND  !DOEND
!ENDDEFINE.
SET MPRINT ON.
!myvars dlist = [1 2 3 4 5] ilist = [1 2 4 8 9] .
EXECUTE.
!myvars dlist = [1 2 3 4 5] ilist = [1 2 4 8 9] .

COMPUTE var1sub1 =0.
COMPUTE var1sub2 =0.
COMPUTE var1sub4 =0.
COMPUTE var1sub8 =0.
COMPUTE var1sub9 =0.
COMPUTE var2sub1 =0.
....

COMPUTE var5sub1 =0.
COMPUTE var5sub2 =0.
COMPUTE var5sub4 =0.
COMPUTE var5sub8 =0.
COMPUTE var5sub9 =0.


anitha.un wrote
Welll...thank you sooo much. I appreciate your help on this.  And also i was trying to do the same using arrays, below is the syntax . My output should create variables like var1sub1, var1sub2. var1sub4, var1sub8 var1sub9, var2sub1, var2sub2,var2sub4, var2sub8, var2sub9.

Define !myvars().
!dlist = [1 2 3 4 5].
!ilist = [1 2 4 8 9].
!ddim = len(!dlist) numeric.
!idim = len(!ilist) numeric.
     !do !i = 1 !to !ddim.
          !LET !mydvar = !CONCAT('var',!dlist(!i)).
     !do !j = 1 !to !idim.
          !LET !myivar = !CONCAT('sub',!ilist(!j)).
      !myfvar= !CONCAT(!mydvar,!myivar).
COMPUTE !myfvar=0.
!DOEND.
!DOEND.
!ENDDEFINE.
myvars.
EXECUTE.

Can you help me out to trouble shoot the error i got : The first word in the line is not recognized as an SPSS Statistics command.This command not executed. I am still a beginner in spss macros, so i feel there may be a small mistake.
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?"
Reply | Threaded
Open this post in threaded view
|

Re: Error : The first word in the line is not recognized as an SPSS Statistics command.

Art Kendall
However, unless one were going to have similar tasks over time using macros for this might be using a sledge hammer on a tack.

Using cut-and-paste and vertical alignment  or using autofill in a a word processor like WordPerfect might be faster than trying to learn macros. YMMV.


Art
On 12/2/2011 2:23 PM, David Marso wrote:
You are making it *WAY TOO COMPLICATED*!!!
SPSS Macro knows *NOTHING* of "arrays" much or less anything of array
indexes.
MACRO is simply a string parser with minimal functionality beyond !HEAD,
!TAIL, !CONCAT, !SUBSTR.
It flunked *MATH* in grade school and was invented when wheels were square
and computers only had ones (zero had yet to be discovered).   However in
the right hands can build a primitive rocket ship from bear skins and flint
shards.
You *CAN NOT* extend MACRO with constructs such as:  !ddim = len(!dlist)
numeric or !ilist(!j).
It is also quite innocent of *most* things common to most "languages".
The following achieves what I infer you to be attempting.

DEFINE !myvars( DLIST !ENCLOSE("[","]")
              / ILIST !ENCLOSE("[","]") ).
!DO !ddim !IN (!DLIST) !DO !idim !IN (!ILIST)
COMPUTE !CONCAT('var',!ddim , 'sub', !idim) =0.
!DOEND  !DOEND
!ENDDEFINE.
SET MPRINT ON.
!myvars dlist = [1 2 3 4 5] ilist = [1 2 4 8 9] .
EXECUTE.
!myvars dlist = [1 2 3 4 5] ilist = [1 2 4 8 9] .

COMPUTE var1sub1 =0.
COMPUTE var1sub2 =0.
COMPUTE var1sub4 =0.
COMPUTE var1sub8 =0.
COMPUTE var1sub9 =0.
COMPUTE var2sub1 =0.
....

COMPUTE var5sub1 =0.
COMPUTE var5sub2 =0.
COMPUTE var5sub4 =0.
COMPUTE var5sub8 =0.
COMPUTE var5sub9 =0.



anitha.un wrote
Welll...thank you sooo much. I appreciate your help on this.  And also i
was trying to do the same using arrays, below is the syntax . My output
should create variables like var1sub1, var1sub2. var1sub4, var1sub8
var1sub9, var2sub1, var2sub2,var2sub4, var2sub8, var2sub9.

Define !myvars().
!dlist = [1 2 3 4 5].
!ilist = [1 2 4 8 9].
!ddim = len(!dlist) numeric.
!idim = len(!ilist) numeric.
     !do !i = 1 !to !ddim.
          !LET !mydvar = !CONCAT('var',!dlist(!i)).
     !do !j = 1 !to !idim.
          !LET !myivar = !CONCAT('sub',!ilist(!j)).
      !myfvar= !CONCAT(!mydvar,!myivar).
COMPUTE !myfvar=0.
!DOEND.
!DOEND.
!ENDDEFINE.
myvars.
EXECUTE.

Can you help me out to trouble shoot the error i got : The first word in
the line is not recognized as an SPSS Statistics command.This command not
executed. I am still a beginner in spss macros, so i feel there may be a
small mistake.


--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Error-The-first-word-in-the-line-is-not-recognized-as-an-SPSS-Statistics-command-tp5036280p5042958.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Error : The first word in the line is not recognized as an SPSS Statistics command.

David Marso
Administrator
OTOH:  Code is already written.  WP and autofill are so let's see? 20th century ;-)
If I were to suggest such a thing I would recommend a freebie such as Open Office or NeoOffice (Mac).
Looks like OP has at least a modicum grasp of something resembling programming so maybe MACRO might be a good investment.  Some pythonistas may disagree but that is another whole debate.
I don't see SPSS removing MACRO from SPSS in the forseeable future.  That would be clearly irresponsible and outright stupid considering the 2+ decades of legacy code in numerous institutions to say nothing of the relative simplicity of MACRO in comparison to languages such as Python, VB, C# etc.
Python )etc) certainly have an elegance and superior power to MACRO but most of the time that extra power is unnecessary and to continue Art's comment akin to taking out a fly on the all with a chainsaw when a B.B. gun or a rubber band in the hands of an expert (or even an attentive novice) is quite adequate.  Python people: Please initiate any ensuing "flame wars" in a separate thread .
Art Kendall wrote
However, unless one were going to have similar tasks
      over time using macros for this might be using a sledge hammer on
      a tack.
     
      Using cut-and-paste and vertical alignment  or using autofill in a
      a word processor like WordPerfect might be faster than trying to
      learn macros. YMMV.
   
   
    Art
    On 12/2/2011 2:23 PM, David Marso wrote:
   
      You are making it *WAY TOO COMPLICATED*!!!
SPSS Macro knows *NOTHING* of "arrays" much or less anything of array
indexes.
MACRO is simply a string parser with minimal functionality beyond !HEAD,
!TAIL, !CONCAT, !SUBSTR.
It flunked *MATH* in grade school and was invented when wheels were square
and computers only had ones (zero had yet to be discovered).   However in
the right hands can build a primitive rocket ship from bear skins and flint
shards.
You *CAN NOT* extend MACRO with constructs such as:  !ddim = len(!dlist)
numeric or !ilist(!j).
It is also quite innocent of *most* things common to most "languages".
The following achieves what I infer you to be attempting.

DEFINE !myvars( DLIST !ENCLOSE("[","]")
              / ILIST !ENCLOSE("[","]") ).
!DO !ddim !IN (!DLIST) !DO !idim !IN (!ILIST)
COMPUTE !CONCAT('var',!ddim , 'sub', !idim) =0.
!DOEND  !DOEND
!ENDDEFINE.
SET MPRINT ON.
!myvars dlist = [1 2 3 4 5] ilist = [1 2 4 8 9] .
EXECUTE.
!myvars dlist = [1 2 3 4 5] ilist = [1 2 4 8 9] .

COMPUTE var1sub1 =0.
COMPUTE var1sub2 =0.
COMPUTE var1sub4 =0.
COMPUTE var1sub8 =0.
COMPUTE var1sub9 =0.
COMPUTE var2sub1 =0.
....

COMPUTE var5sub1 =0.
COMPUTE var5sub2 =0.
COMPUTE var5sub4 =0.
COMPUTE var5sub8 =0.
COMPUTE var5sub9 =0.



anitha.un wrote

     
       
Welll...thank you sooo much. I appreciate your help on this.  And also i
was trying to do the same using arrays, below is the syntax . My output
should create variables like var1sub1, var1sub2. var1sub4, var1sub8
var1sub9, var2sub1, var2sub2,var2sub4, var2sub8, var2sub9.

Define !myvars().
!dlist = [1 2 3 4 5].
!ilist = [1 2 4 8 9].
!ddim = len(!dlist) numeric.
!idim = len(!ilist) numeric.
     !do !i = 1 !to !ddim.
          !LET !mydvar = !CONCAT('var',!dlist(!i)).
     !do !j = 1 !to !idim.
          !LET !myivar = !CONCAT('sub',!ilist(!j)).
      !myfvar= !CONCAT(!mydvar,!myivar).
COMPUTE !myfvar=0.
!DOEND.
!DOEND.
!ENDDEFINE.
myvars.
EXECUTE.

Can you help me out to trouble shoot the error i got : The first word in
the line is not recognized as an SPSS Statistics command.This command not
executed. I am still a beginner in spss macros, so i feel there may be a
small mistake.


     
     

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Error-The-first-word-in-the-line-is-not-recognized-as-an-SPSS-Statistics-command-tp5036280p5042958.html 
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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
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?"
Reply | Threaded
Open this post in threaded view
|

Re: Error : The first word in the line is not recognized as an SPSS Statistics command.

Art Kendall
Removing MACRO would certainly be a great mistake if SPSS were to do it!

Certainly any word processor that has autofill in tables, and rectangular selection of text would do it.  WP just happens to be what I used when PCs came along and I no longer had SED on a screen connected to a mainframe. (yes SED was so -mid-70s.) WP is the only word processor I have seen, although I have not checked in a few years, that has rectangular selection, parses sentences into parts of speech, and gives standard readability indices.

Using cut and paste and vertical alignment is pretty much the same as what macros do
. Doing that a time or two gives a pretty good idea of what macros do.  A good starting exercise.  Even someone with David's level of expertise might trade off readability and speed of QA review and create vertically aligned structure this way when there were only 4 or 5 such lines needed.

<soapbox>  vertical alignment can often enhance the readability of syntax analogous to the use of sense lining when preparing text for oral presentation. E.g., DO space space space IF helps vertical alignment alignment with ELSE space IF and END space space IF.
DO   IF
ELSE IF
END  IF

I first found this a help when I first had a screen editor with rectangular selection 1974ish.  Works in many computer languages, FORTRAN, TECO, BASIC, SPSS, SAS, BMDP,etc.
<\soapbox>

when there are only a few vertically aligned lines needed a model of what a macro would do would be something like this

typing
Var?Sub1, Var?Sub2,Var?Sub4 Var?Sub8
copy and paste that line
edit replace var? with var1
copy and paste that line
edit replace var? with var2
copy and paste that line
edit replace var? with var3
var1Sub1, var1Sub2,var1Sub4 var1Sub8
var2Sub1, var2Sub2,var2Sub4 var2Sub8
var3Sub1, var3Sub2,var3Sub4 var3Sub8

Alternatively
typing the line once and pasting it the needed number of times and then editing vertically works

Var?Sub1, Var?Sub2,Var?Sub4 Var?Sub8
Var?Sub1, Var?Sub2,Var?Sub4 Var?Sub8
Var?Sub1, Var?Sub2,Var?Sub4 Var?Sub8
then vertically edit with type over on 1,2,3 in each column

Art Kendall
Social Research Consultants

On 12/2/2011 9:09 PM, David Marso wrote:
OTOH:  Code is already written.  WP and autofill are so let's see? 20th
century ;-)
If I were to suggest such a thing I would recommend a freebie such as Open
Office or NeoOffice (Mac).
Looks like OP has at least a modicum grasp of something resembling
programming so maybe MACRO might be a good investment.  Some pythonistas may
disagree but that is another whole debate.
I don't see SPSS removing MACRO from SPSS in the forseeable future.  That
would be clearly irresponsible and outright stupid considering the 2+
decades of legacy code in numerous institutions to say nothing of the
relative simplicity of MACRO in comparison to languages such as Python, VB,
C# etc.
Python )etc) certainly have an elegance and superior power to MACRO but most
of the time that extra power is unnecessary and to continue Art's comment
akin to taking out a fly on the all with a chainsaw when a B.B. gun or a
rubber band in the hands of an expert (or even an attentive novice) is quite
adequate.  Python people: Please initiate any ensuing "flame wars" in a
separate thread .

Art Kendall wrote
However, unless one were going to have similar tasks
      over time using macros for this might be using a sledge hammer on
      a tack.

      Using cut-and-paste and vertical alignment&nbsp; or using autofill
in a
      a word processor like WordPerfect might be faster than trying to
      learn macros. YMMV.


    Art
    On 12/2/2011 2:23 PM, David Marso wrote:

      You are making it *WAY TOO COMPLICATED*!!!
SPSS Macro knows *NOTHING* of "arrays" much or less anything of array
indexes.
MACRO is simply a string parser with minimal functionality beyond !HEAD,
!TAIL, !CONCAT, !SUBSTR.
It flunked *MATH* in grade school and was invented when wheels were square
and computers only had ones (zero had yet to be discovered).   However in
the right hands can build a primitive rocket ship from bear skins and
flint
shards.
You *CAN NOT* extend MACRO with constructs such as:  !ddim = len(!dlist)
numeric or !ilist(!j).
It is also quite innocent of *most* things common to most "languages".
The following achieves what I infer you to be attempting.

DEFINE !myvars( DLIST !ENCLOSE("[","]")
              / ILIST !ENCLOSE("[","]") ).
!DO !ddim !IN (!DLIST) !DO !idim !IN (!ILIST)
COMPUTE !CONCAT('var',!ddim , 'sub', !idim) =0.
!DOEND  !DOEND
!ENDDEFINE.
SET MPRINT ON.
!myvars dlist = [1 2 3 4 5] ilist = [1 2 4 8 9] .
EXECUTE.
!myvars dlist = [1 2 3 4 5] ilist = [1 2 4 8 9] .

COMPUTE var1sub1 =0.
COMPUTE var1sub2 =0.
COMPUTE var1sub4 =0.
COMPUTE var1sub8 =0.
COMPUTE var1sub9 =0.
COMPUTE var2sub1 =0.
....

COMPUTE var5sub1 =0.
COMPUTE var5sub2 =0.
COMPUTE var5sub4 =0.
COMPUTE var5sub8 =0.
COMPUTE var5sub9 =0.



anitha.un wrote



Welll...thank you sooo much. I appreciate your help on this.  And also i
was trying to do the same using arrays, below is the syntax . My output
should create variables like var1sub1, var1sub2. var1sub4, var1sub8
var1sub9, var2sub1, var2sub2,var2sub4, var2sub8, var2sub9.

Define !myvars().
!dlist = [1 2 3 4 5].
!ilist = [1 2 4 8 9].
!ddim = len(!dlist) numeric.
!idim = len(!ilist) numeric.
     !do !i = 1 !to !ddim.
          !LET !mydvar = !CONCAT('var',!dlist(!i)).
     !do !j = 1 !to !idim.
          !LET !myivar = !CONCAT('sub',!ilist(!j)).
      !myfvar= !CONCAT(!mydvar,!myivar).
COMPUTE !myfvar=0.
!DOEND.
!DOEND.
!ENDDEFINE.
myvars.
EXECUTE.

Can you help me out to trouble shoot the error i got : The first word in
the line is not recognized as an SPSS Statistics command.This command not
executed. I am still a beginner in spss macros, so i feel there may be a
small mistake.





--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Error-The-first-word-in-the-line-is-not-recognized-as-an-SPSS-Statistics-command-tp5036280p5042958.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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


--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Error-The-first-word-in-the-line-is-not-recognized-as-an-SPSS-Statistics-command-tp5036280p5043650.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Error : The first word in the line is not recognized as an SPSS Statistics command.

Jon K Peck
I have not heard anyone inside IBM SPSS even suggest removing macro from Statistics.  Even I do not suggest that, much as I dislike macro.  However, IMO it is only the tool of choice when you want to construct a simple shorthand list to plug into other syntax or if you must support ancient (pre V14) versions - or ancient users.  Python programmability and scripting are much more powerful while being much easier to learn and use.  There are much better debugging tools available for programmability, as well.  So I hate to see anyone in the modern era start down the path of mastering macro.

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        Art Kendall <[hidden email]>
To:        [hidden email]
Date:        12/03/2011 07:26 AM
Subject:        Re: [SPSSX-L] Error : The first word in the line is not              recognized as an              SPSS Statistics command.
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Removing MACRO would certainly be a great mistake if SPSS were to do it!

Certainly any word processor that has autofill in tables, and rectangular selection of text would do it.  WP just happens to be what I used when PCs came along and I no longer had SED on a screen connected to a mainframe. (yes SED was so -mid-70s.) WP is the only word processor I have seen, although I have not checked in a few years, that has rectangular selection, parses sentences into parts of speech, and gives standard readability indices.

Using cut and paste and vertical alignment is pretty much the same as what macros do
. Doing that a time or two gives a pretty good idea of what macros do.  A good starting exercise.  Even someone with David's level of expertise might trade off readability and speed of QA review and create vertically aligned structure this way when there were only 4 or 5 such lines needed.

<soapbox>  vertical alignment can often enhance the readability of syntax analogous to the use of sense lining when preparing text for oral presentation. E.g., DO space space space IF helps vertical alignment alignment with ELSE space IF and END space space IF.

DO   IF
ELSE IF
END  IF

I first found this a help when I first had a screen editor with rectangular selection 1974ish.  Works in many computer languages, FORTRAN, TECO, BASIC, SPSS, SAS, BMDP,etc.
<\soapbox>

when there are only a few vertically aligned lines needed a model of what a macro would do would be something like this

typing
Var?Sub1, Var?Sub2,Var?Sub4 Var?Sub8
copy and paste that line
edit replace var? with var1
copy and paste that line
edit replace var? with var2
copy and paste that line
edit replace var? with var3

var1Sub1, var1Sub2,var1Sub4 var1Sub8
var2Sub1, var2Sub2,var2Sub4 var2Sub8
var3Sub1, var3Sub2,var3Sub4 var3Sub8

Alternatively
typing the line once and pasting it the needed number of times and then editing vertically works

Var?Sub1, Var?Sub2,Var?Sub4 Var?Sub8
Var?Sub1, Var?Sub2,Var?Sub4 Var?Sub8
Var?Sub1, Var?Sub2,Var?Sub4 Var?Sub8

then vertically edit with type over on 1,2,3 in each column

Art Kendall
Social Research Consultants

On 12/2/2011 9:09 PM, David Marso wrote:

OTOH:  Code is already written.  WP and autofill are so let's see? 20th
century ;-)
If I were to suggest such a thing I would recommend a freebie such as Open
Office or NeoOffice (Mac).
Looks like OP has at least a modicum grasp of something resembling
programming so maybe MACRO might be a good investment.  Some pythonistas may
disagree but that is another whole debate.
I don't see SPSS removing MACRO from SPSS in the forseeable future.  That
would be clearly irresponsible and outright stupid considering the 2+
decades of legacy code in numerous institutions to say nothing of the
relative simplicity of MACRO in comparison to languages such as Python, VB,
C# etc.
Python )etc) certainly have an elegance and superior power to MACRO but most
of the time that extra power is unnecessary and to continue Art's comment
akin to taking out a fly on the all with a chainsaw when a B.B. gun or a
rubber band in the hands of an expert (or even an attentive novice) is quite
adequate.  Python people: Please initiate any ensuing "flame wars" in a
separate thread .

Art Kendall wrote


However, unless one were going to have similar tasks
     over time using macros for this might be using a sledge hammer on
     a tack.

     Using cut-and-paste and vertical alignment&nbsp; or using autofill
in a
     a word processor like WordPerfect might be faster than trying to
     learn macros. YMMV.


   Art
   On 12/2/2011 2:23 PM, David Marso wrote:

     You are making it *WAY TOO COMPLICATED*!!!
SPSS Macro knows *NOTHING* of "arrays" much or less anything of array
indexes.
MACRO is simply a string parser with minimal functionality beyond !HEAD,
!TAIL, !CONCAT, !SUBSTR.
It flunked *MATH* in grade school and was invented when wheels were square
and computers only had ones (zero had yet to be discovered).   However in
the right hands can build a primitive rocket ship from bear skins and
flint
shards.
You *CAN NOT* extend MACRO with constructs such as:  !ddim = len(!dlist)
numeric or !ilist(!j).
It is also quite innocent of *most* things common to most "languages".
The following achieves what I infer you to be attempting.

DEFINE !myvars( DLIST !ENCLOSE("[","]")
             / ILIST !ENCLOSE("[","]") ).
!DO !ddim !IN (!DLIST) !DO !idim !IN (!ILIST)
COMPUTE !CONCAT('var',!ddim , 'sub', !idim) =0.
!DOEND  !DOEND
!ENDDEFINE.
SET MPRINT ON.
!myvars dlist = [1 2 3 4 5] ilist = [1 2 4 8 9] .
EXECUTE.
!myvars dlist = [1 2 3 4 5] ilist = [1 2 4 8 9] .

COMPUTE var1sub1 =0.
COMPUTE var1sub2 =0.
COMPUTE var1sub4 =0.
COMPUTE var1sub8 =0.
COMPUTE var1sub9 =0.
COMPUTE var2sub1 =0.
....

COMPUTE var5sub1 =0.
COMPUTE var5sub2 =0.
COMPUTE var5sub4 =0.
COMPUTE var5sub8 =0.
COMPUTE var5sub9 =0.



anitha.un wrote



Welll...thank you sooo much. I appreciate your help on this.  And also i
was trying to do the same using arrays, below is the syntax . My output
should create variables like var1sub1, var1sub2. var1sub4, var1sub8
var1sub9, var2sub1, var2sub2,var2sub4, var2sub8, var2sub9.

Define !myvars().
!dlist = [1 2 3 4 5].
!ilist = [1 2 4 8 9].
!ddim = len(!dlist) numeric.
!idim = len(!ilist) numeric.
    !do !i = 1 !to !ddim.
         !LET !mydvar = !CONCAT('var',!dlist(!i)).
    !do !j = 1 !to !idim.
         !LET !myivar = !CONCAT('sub',!ilist(!j)).
     !myfvar= !CONCAT(!mydvar,!myivar).
COMPUTE !myfvar=0.
!DOEND.
!DOEND.
!ENDDEFINE.
myvars.
EXECUTE.

Can you help me out to trouble shoot the error i got : The first word in
the line is not recognized as an SPSS Statistics command.This command not
executed. I am still a beginner in spss macros, so i feel there may be a
small mistake.





--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Error-The-first-word-in-the-line-is-not-recognized-as-an-SPSS-Statistics-command-tp5036280p5042958.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@.UGA  (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
LISTSERV@.UGA (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




--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Error-The-first-word-in-the-line-is-not-recognized-as-an-SPSS-Statistics-command-tp5036280p5043650.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@... (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
|

Re: Error : The first word in the line is not recognized as an SPSS Statistics command.

anitha.un
In reply to this post by David Marso
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Error : The first word in the line is not recognized as an SPSS Statistics command.

anitha.un
In reply to this post by David Marso
CONTENTS DELETED
The author has deleted this message.