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:         Sat, 3 Dec 2011 09:22:47 -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.
Comments: To: David Marso <david.marso@gmail.com>
In-Reply-To:  <1322878163402-5043650.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">Removing MACRO would certainly be a great mistake if SPSS were to do it!<br> <br> Certainly any word processor that has autofill in tables, and rectangular selection of text would do it.&nbsp; 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.<br> <br> Using cut and paste and vertical alignment is pretty much the same as what macros do</font>. Doing that a time or two gives a pretty good idea of what macros do.&nbsp; A good starting exercise.&nbsp; 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.<br> <br> &lt;soapbox&gt;&nbsp; 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. <br> <tt>DO&nbsp;&nbsp; IF<br> ELSE IF<br> END&nbsp; IF</tt><br> I first found this a help when I first had a screen editor with rectangular selection 1974ish.&nbsp; Works in many computer languages, FORTRAN, TECO, BASIC, SPSS, SAS, BMDP,etc.<br> &lt;\soapbox&gt;<br> <br> when there are only a few vertically aligned lines needed a model of what a macro would do would be something like this<br> <br> typing<br> Var?Sub1, Var?Sub2,Var?Sub4 Var?Sub8<br> copy and paste that line<br> edit replace var? with var1<br> copy and paste that line<br> edit replace var? with var2<br> copy and paste that line<br> edit replace var? with var3<br> <pre wrap="">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 </pre> then vertically edit with type over on 1,2,3 in each column<br> <br> Art Kendall<br> Social Research Consultants<br> <br> On 12/2/2011 9:09 PM, David Marso wrote: <blockquote cite="mid:1322878163402-5043650.post@n5.nabble.com" type="cite"> <pre wrap="">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 </pre> <blockquote type="cite"> <pre wrap=""> 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&amp;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: <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@.UGA">LISTSERV@.UGA</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

===================== To manage your subscription to SPSSX-L, send a message to <a class="moz-txt-link-abbreviated" href="mailto:LISTSERV@.UGA">LISTSERV@.UGA</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> <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-tp5036280p5043650.html">http://spssx-discussion.1045642.n5.nabble.com/Error-The-first-word-in-the-line-is-not-recognized-as-an-SPSS-Statistics-command-tp5036280p5043650.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


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