Date: Sun, 3 Dec 2000 10:39:32 -0500
Reply-To: Raynald Levesque <rlevesque@VIDEOTRON.CA>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Raynald Levesque <rlevesque@VIDEOTRON.CA>
Subject: Re: Variable Labeling After Restructure
In-Reply-To: <3.0.3.32.20001201122943.00818bf0@syzygy.email.umn.edu>
Content-Type: text/plain; charset="iso-8859-1"
Hi Carol!
This is one way of doing it:
DATA LIST LIST /id.
BEGIN DATA
1
END DATA.
NUMERIC pw1 TO pw4 bp1 TO bp4.
SET MPRINT=yes.
DEFINE !label (lab=!TOKENS(1)
/stem=!TOKENS(1)
/nb1=!TOKENS(1)
/nb2=!TOKENS(1))
!DO !cnt=!nb1 !TO !nb2
!LET !var=!CONCAT(!stem,!cnt)
!LET !labe=!QUOTE(!CONCAT(!UNQUOTE(!lab),!cnt))
VARIABLE LABEL !var !labe.
!DOEND.
!ENDDEFINE.
* Call macro.
!label lab='Blood Pressure - Week ' stem=bp nb1=1 nb2=4.
!label lab='Patient Weight - Week ' stem=pw nb1=1 nb2=4.
HTH
Raynald Levesque rlevesque@videotron.ca
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On Behalf Of
Carol Albright
Sent: Friday, December 01, 2000 1:30 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: Variable Labeling After Restructure
Hi, SPSS-ers,
Say I just restructured my data set from a many records per case to
a one
record per case (but with many more variables). Using the VECTOR trick,
you can create and populate many variables. But how do I LABEL them?
Example: My original data set has ID, DATE, BP and WT. My new data
set
has ID, BP1 to BP#, WT1 to WT#, where # is the maximum number of weeks I
collected data. BP# and WT# are created using VECTOR, and thus do not have
variable labels.
Can some macro guru create a program to take this ...
VAR LABELS
ID "Patient ID"
BP "Blood Pressure"
WT "Patient Weight".
and creates this ...
VAR LABELS
ID "Patient ID"
BP1 "Blood Pressure - Week 1"
WT1 "Patient Weight - Week 1"
BP2 "Blood Pressure - Week 2"
WT2 "Patient Weight - Week 2"
etc etc.
Can you do something along the line of:
<macro magic here>
VAR LABELS
BP# "Blood Pressure" TIME #
WT# "Weight" TIME #.
ie take the variable name stem plus a placeholder that increments through
the # of time periods (week in this case), the original variable label plus
a placeholder for the key word (change to "Week") and again the # that
should match the variable name. Would sure beat my current search &
replace method.
TIA!
Carol
-------------------------------------------------------------------------
Carol L. Albright, MS | E-Mail : syzygy@tc.umn.edu
Albright Consulting | Phone : 651/699-7218
2031 Goodrich Avenue | http://www.tc.umn.edu/~syzygy
St. Paul, MN 55105 USA | Research data services
-------------------------------------------------------------------------