LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2011)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 2 Dec 2011 11:23:19 -0800
Reply-To:     David Marso <david.marso@gmail.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         David Marso <david.marso@gmail.com>
Subject:      Re: Error : The first word in the line is not recognized as an
              SPSS Statistics command.
In-Reply-To:  <1322846965631-5042683.post@n5.nabble.com>
Content-Type: text/plain; charset=us-ascii

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


Back to: Top of message | Previous page | Main SPSSX-L page