Date: Mon, 19 Dec 2011 15:13:58 -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: <OF8F49BAE5.1417454A-ON8725796B.007D0606-8725796B.007D666D@us.ibm.com>
Content-Type: multipart/alternative;
Jon,
Sep_Oct_2011_credits_credits should have had only one credits. Typo.
This is a growing file that I add a field to every time I match a newer
file of credits to it. So I need the accumulating records of what has
been credited each month. The "Sep_Oct_2011" part corresponds to the
file the credit came from. It's not related to a current date.
I could imagine that this would be easy to do in Python, but since I
want a variable that represents the date portion of the field to be
available throughout the syntax I'd have to include all of the syntax in
a python program, right? Or is there another way.
Thanks
Matt
Matthew Pirritano, Ph.D.
Research Analyst IV
Medical Services Initiative (MSI)
Orange County Health Care Agency
(714) 568-5648
________________________________
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
Jon K Peck
Sent: Monday, December 19, 2011 2:50 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: Re: macro to replace portions of variable names in syntax file
This could be done more easily using Python regular expressions. You
might open a template syntax file into a syntax window; then run a small
Python program to update the template to the particular dates you want,
and then run it from there. But this problem appears to be a little
more complicated. What is the logic that would apply to names like
_Sep_Oct_2011_credits_credits?
p.s. There is a function in spssaux2.py named CreateFileNameWDate that
automatically picks up the current date in generating a file name.
Regards,
Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
peck@us.ibm.com
new phone: 720-342-5621
From: Rich Ulrich <rich-ulrich@live.com>
To: SPSSX-L@listserv.uga.edu
Date: 12/19/2011 02:27 PM
Subject: Re: [SPSSX-L] macro to replace portions of variable
names in syntax file
Sent by: "SPSSX(r) Discussion" <SPSSX-L@listserv.uga.edu>
________________________________
The simplest and most transparent way may be the old-fashioned one -
Create a basic syntax file with a dummy date, e.g., XXX_XXX.
Then, for the monthly processing, create the Report file, which will -
1) read your basic syntax file as a single Text variable per line;
2) use sub-string replacement in order to replace XXX_XXX with
your desired date, e.g., Sep_Oct;
3) "write" out the file as Text and close it;
4) "Include" the new text file to run it.
Each month, you change the desired date, and then run the Report.
--
Rich Ulrich
________________________________
Date: Mon, 19 Dec 2011 12:57:25 -0800
From: MPirritano@ochca.com
Subject: macro to replace portions of variable names in syntax file
To: SPSSX-L@LISTSERV.UGA.EDU
All,
I like being able to update the dates on my files using this simple
macro:
DEFINE !filedate() '20111219' !ENDDEFINE.
But now I have variable names that have a date embedded in them. I want
to update all instances of those variable names with something like a
macro.
For example, a typical command might be:
if (Sep_Oct_2011_credits = 1)
priordebitmatched_Sep_Oct_2011_credits_credits = 1.
I want to change the month and date portions since they will change
every time I run the file, and I don't want to have to convert all the
syntax to a macro. That seems overkill.
[...]
[text/html]