Date: Fri, 2 Dec 2011 15:05:38 -0500
Reply-To: Art@DrKendall.org
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Art Kendall <Art@DrKendall.org>
Organization: Social Research Consultants
Subject: Re: Error : The first word in the line is not recognized as an
SPSS Statistics command.
In-Reply-To: <1322853799585-5042958.post@n5.nabble.com>
Content-type: text/html; charset=ISO-8859-1
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font size="+1">However, unless one were going to have similar tasks
over time using macros for this might be using a sledge hammer on
a tack.<br>
<br>
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.<br>
</font><br>
<br>
Art<br>
On 12/2/2011 2:23 PM, David Marso wrote:
<blockquote cite="mid:1322853799585-5042958.post@n5.nabble.com"
type="cite">
<pre wrap="">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
</pre>
<blockquote type="cite">
<pre wrap="">
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.
</pre>
</blockquote>
<pre wrap="">
--
View this message in context: <a class="moz-txt-link-freetext" href="http://spssx-discussion.1045642.n5.nabble.com/Error-The-first-word-in-the-line-is-not-recognized-as-an-SPSS-Statistics-command-tp5036280p5042958.html">http://spssx-discussion.1045642.n5.nabble.com/Error-The-first-word-in-the-line-is-not-recognized-as-an-SPSS-Statistics-command-tp5036280p5042958.html</a>
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
=====================
To manage your subscription to SPSSX-L, send a message to
<a class="moz-txt-link-abbreviated" href="mailto:LISTSERV@LISTSERV.UGA.EDU">LISTSERV@LISTSERV.UGA.EDU</a> (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
</pre>
</blockquote>
</body>
</html>
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (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