delimiters within macros

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

srejgn
Posts: 3
Joined: Wed Jul 30, 2014 12:17 pm

delimiters within macros

Postby srejgn » Wed Jul 30, 2014 12:28 pm

hi,

i am trying to do the following:

!let !list = "simple(1) simple(2)"
!let !a = !head(!list)

to return !a = simple(1)


or more specifically:

!do !a !in(!list)
...
!doend

to result in two passes where !a first is "simple(1)" and then !a is "simple(2)".

when i do this !a takes on values of simple, (, 1, ), simple, (, 2, ).

any help is appreciated!

thank you!

eugene
RubenGeert
Posts: 100
Joined: Mon May 19, 2014 6:06 am

Re: delimiters within macros

Postby RubenGeert » Thu Jul 31, 2014 5:33 am

The best advice - by far - I can give you on this, is to start using Python and stop wasting time and effort on the old, obsolete macros in SPSS. For a quick introduction, see http://www.spss-tutorials.com/introduci ... t-and-why/

Kind regards,

Ruben
srejgn
Posts: 3
Joined: Wed Jul 30, 2014 12:17 pm

Re: delimiters within macros

Postby srejgn » Thu Jul 31, 2014 6:02 am

thank you for the "python" suggestion, but this is not an option. i need to be able to do this within spss.
RubenGeert
Posts: 100
Joined: Mon May 19, 2014 6:06 am

Re: delimiters within macros

Postby RubenGeert » Thu Jul 31, 2014 12:00 pm

OK, that's a bit of a pity...

Just curiosity, could you tell me why are you not able to use Python for your project? Although I'm on SPSS version 20 myself, I heard that Python has kinda been "incorporated" into the most recent version(s) such that it is no longer really an external program to SPSS. I've no idea to what extent that may be helpful for you but just wanted to inform you on that.

Kind regards,

Ruben
srejgn
Posts: 3
Joined: Wed Jul 30, 2014 12:17 pm

Re: delimiters within macros

Postby srejgn » Thu Jul 31, 2014 12:30 pm

it is a long story, but let me try and make it short... we have a battery of macros that are called via a user interface. the macros have been around since 1995, and work as far back as SPSS 11. we use these in workshops all over the world with all sort of spss versions. all the user needs is spss. while in the future we are actually considering converting all to R, we are not at that stage yet.

the interface allows them to select the type of analysis, and variables that go with it. in the specific case i am inquiring about, we are implementing logistic regression with contrasts and a reference category for categorical variables. the issue is that some contrasts take in a reference category, whereas others do not, and the reference category is enclosed in parenthesis.

define JB_LogReg
(catvar = !charend('/') !default("") /
contrast= !charend('/') !default("") ).
.
.
.
!enddefine.

i want to feed this:
jb_logreg catvar = catvar1 catvar2 catvar3
/ contrast = simple(1) helmert indicator(2)

and i want it to resolve to this:
/ contrasts catvar1 = simple(1)
/ contrasts catvar2 = helmert
/ contrasts catvar3 = indicator(2)

in similar circumstances i use a series or '!do !in', '!head' and '!tail' command to pair up first with first, second with second, etc... but this would only work if i can force the delimiter for the '!do !in' loop to be a space, and only a space.

i know i could do:
jb_logreg catvar = catvar1 catvar2 catvar3
/ contrast = simple helmert indicator
/ refcats = 1 X 2

(the X in refcats being a placeholder for the contrast that does not take a reference category)
but am trying to simplify it so the call would look more like i would specify it if i were using the syntax editor.

Who is online

Users browsing this forum: No registered users and 4 guests

cron