Date: Tue, 20 Dec 2011 11:18:13 -0800
Reply-To: "Pirritano, Matthew" <MPirritano@ochca.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: "Pirritano, Matthew" <MPirritano@ochca.com>
Subject: Re: macro to replace portions of variable names in syntax file
In-Reply-To: <BLU143-W2987954AA3F9638F41033C97A40@phx.gbl>
Content-Type: multipart/alternative;
Thanks Rich,
I'm not sure I'm clear on what people are calling a template. Is there
an actual spss syntax file custom template? Or do you just mean a
template in the generic sense of a preset file format? Or is it
something else?
Are you talking about doing text substitution using python? Or are you
talking about an old-style spss macro? Or doing find-replace?
I guess I wasn't too clear on the procedure you were describing. If it's
not too much to ask, could you provide a little more detail?
Thanks
Matt
Matthew Pirritano, Ph.D.
Research Analyst IV
Medical Services Initiative (MSI)
Orange County Health Care Agency
(714) 568-5648
________________________________
From: Rich Ulrich [mailto:rich-ulrich@live.com]
Sent: Tuesday, December 20, 2011 11:09 AM
To: Pirritano, Matthew; SPSS list
Subject: RE: macro to replace portions of variable names in syntax file
Read a template, substitute for some text, write the result somewhere
and then run it. That's the way that I read the original post.
My old-style solution still looks pretty easy, compared to what I've
read, which mostly tackle other problems.
The text substitution can be more complicated than I wrote -- when the
new
and old are not exactly the same length, you have to copy the old line
into
a new line before writing it, to accommodate a longer or shorter text.
--
Rich Ulrich
> Date: Tue, 20 Dec 2011 08:31:23 -0800
> From: MPirritano@ochca.com
> Subject: Re: macro to replace portions of variable names in syntax
file
> To: SPSSX-L@LISTSERV.UGA.EDU
>
> David et al.,
>
> Apologies if my original post wasn't clear. I think Jon and Albert-Jan
> were on the right track. I have yet to try Albert-Jan's solution.
>
> What I want is simply a constant.
>
> Like in python I could just say:
>
> X = "Hello"
>
> And then plug that in wherever else I want in the syntax. To be able
to
> use a constant that is not expressly a string, like Sep_Oct_2011 (no
> quotes), as part of a variable name. So that I could just say X =
> Sep_Oct_2011 and then plug X in wherever I wanted to do the
replacement.
> That is what I was using the macro syntax to define my file dates as.
I
> don't need to parse the date string to equal anything. 20111219
doesn't
> have to equal Nov_Dec_2011. In fact it was silly of me to call my
> variable MMM_MMM_YYYY. I changed it from Sep_Oct_2011 to
090111_103111,
> for my sep to oct file name. I prefer YYYYMMDD, but the person who is
> sending me files uses MMDDYY.
>
[snip, previous]
[text/html]