data for analysis

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

data for analysis

Rima
I have date of last menstruations, date of examination, how can I create new variable - women with menopause 1, women without menopause 0, if menopause is one year after last menstuation date?
Reply | Threaded
Open this post in threaded view
|

Automatic reply: data for analysis

MacGillivary Heather L


Jeffco Public Schools is closed the week of Thankgiving due to budget cuts.  I will respond to emails on Monday November 28th.

Have a wonderful holiday.

Heather

Reply | Threaded
Open this post in threaded view
|

Automatic reply: data for analysis

Kevan Edwards (MDH)
In reply to this post by Rima

I am currently out of the office and will return on Monday Nov 28.  I will be checking my email once per day and responding  to urgent matters only.   Otherwise I will respond to your email when I return.

 

Thank You! 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: data for analysis

Art Kendall
In reply to this post by Rima
Something like the example syntax below should work for you.
Open a new instance of SPSS.
Copy and paste the syntax into a syntax window.
Run it.
See if this covers the possibilities you might encounter.

Art Kendall
Social Research Consultants

data list list/ id (f5) menstrdate examdate (2adate10).
begin data
    1 Mar-1-1995 APR-10-1996
    2 mar-1-1995 apr-10-2006
    3 mar-1-1995 mar-3-1995
    4 mar-1-1995 feb-28-1996
    5 mar-1-1995 mar-1-1996
    6 mar-1-1995 mar-2-1996
    7 mar-1-1995 feb-28-1995
    8 mar-1-1995 mar-1-1800
    9 Mar-1-1800 mar-1-1996
end data.
missing values menstrdate examdate("mar-1-1800").
do if nvalid(menstrdate, examdate) eq 2.
    do if examdate ge menstrdate.
       compute menopause = datediff(examdate,menstrdate,"years") ge 1.
    ELSE.
       compute menopause = -2.
    end if.
ELSE.
    compute menopause = -1.
end if.
missing values menopause (lo thru -1).
value labels menopause
    0 'without menopause'
    1 'with menopause'
    -1 'not computable missing input'
    -2 'not computable dates unreasonable'.
formats menopause (f2).
list.




On 11/19/2011 11:49 AM, Rima wrote:

> I have date of last menstruations, date of examination, how can I create new
> variable - women with menopause 1, women without menopause 0, if menopause
> is one year after last menstuation date?
>
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/data-for-analysis-tp5007085p5007085.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (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
[hidden email] (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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

syntax for repeating tables and changing title

J P-6
In reply to this post by Rima
Good morning,

I am having no luck trying to figure out what ought to be a doable task.

I need to create syntax that will produce 30 CTABLES using the same variables but for different subsets of data AND I would like to pass the numeric increment and text from fields in the data file to the TITLE of each table. I thought this can be done using a macro but I am not having any luck.

In other words, the same CTABLES would be repeated 30 times but with a different title for each run.

For example each title would read: Table 1. abcd.  to Table 30. xyz . Where x = numeric id of subset and abc to xyz is text, both of which are variables in the data file.

Any advice is greatly appreciated.

Thank you,
John


Reply | Threaded
Open this post in threaded view
|

Re: syntax for repeating tables and changing title

David Marso
Administrator
John,
See !DO !DOEND to loop, to parse parallel lists see !HEAD, !TAIL
Also, start a *NEW* topic rather than changing the subject of an existing topic.
Threading goes FUBAR in Nabble archives.
----
Here is a simplest possible example.
data list free / seg x y.
begin data
 1 1 1  1 1 2  1 2 1  1 2 2  2 1 1  2 1 2  2 2 1  2 2 2  3 1 1  3 1 2  3 2 1  3 2 2
end data.

VARIABLE LEVEL x y (NOMINAL).
DEFINE TABIT (SEGS !ENCLOSE("(",")")/ TITLES !ENCLOSE("(",")") )
!LET !TCOPY=!TITLES
!DO !SEG !IN (!SEGS)
!LET !TITLE = !HEAD(!TCOPY) !LET !TCOPY = !TAIL(!TCOPY)
TEMPORARY.
SELECT IF (SEG = !SEG).
CTABLES  /TABLE x BY y   /TITLES TITLE= !QUOTE(!TITLE).
!DOEND .
!ENDDEFINE.  
SET MPRINT ON.
TABIT SEGS (1 2 3) TITLES ( A B C).

In the future, Please post your attempts at any MACRO you seek assistance with.
You will have to feed the parameter values to the macro rather than access them from the data.
OTOH, such can be done with Python but might be a royal PITA (cursors and all that...)
HTH, David
J P-6 wrote
Good morning,

I am having no luck trying to figure out what ought to be a doable task.

I need to create syntax that will produce 30 CTABLES using the same variables but for different subsets of data AND I would like to pass the numeric increment and text from fields in the data file to the TITLE of each table. I thought this can be done using a macro but I am not having any luck.

In other words, the same CTABLES would be repeated 30 times but with a different title for each run.

For example each title would read: Table 1. abcd.  to Table 30. xyz . Where x = numeric id of subset and abc to xyz is text, both of which are variables in the data file.

Any advice is greatly appreciated.

Thank you,
John
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: syntax for repeating tables and changing title

Jon K Peck
In reply to this post by J P-6
You would need Python code to feed data into the titling.  Sequence numbering could be done in the Python code, or you could use the SPSSINC MODIFY OUTPUT extension command to do sequence numbering in a variety of styles (even roman numerals).

To be more specific, we would need to know what the data structure is for the titling and selection parts.  That could be very easy if the data are suitable.

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        J P <[hidden email]>
To:        [hidden email]
Date:        11/20/2011 10:02 AM
Subject:        [SPSSX-L] syntax for repeating tables and changing title
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Good morning,

I am having no luck trying to figure out what ought to be a doable task.

I need to create syntax that will produce 30 CTABLES using the same variables but for different subsets of data AND I would like to pass the numeric increment and text from fields in the data file to the TITLE of each table. I thought this can be done using a macro but I am not having any luck.

In other words, the same CTABLES would be repeated 30 times but with a different title for each run.

For example each title would read: Table 1. abcd.  to Table 30. xyz . Where x = numeric id of subset and abc to xyz is text, both of which are variables in the data file.

Any advice is greatly appreciated.

Thank you,
John


Reply | Threaded
Open this post in threaded view
|

Re: syntax for repeating tables and changing title

Ruben Geert van den Berg
In reply to this post by David Marso
Dear John (and others),

I'm not entirely sure whether I understand you correctly, but in case I do, the syntax below illustrates a possible approach. This should work no matter how many groups there may be. No need to manually type out the group names/numbers. The Python code is probably somewhat inefficient, if anyone has any suggestions for improvement, I'd be very grateful.

HTH,

Ruben

*Fake data.

data list free/group(a11) gender grade.
begin data
"tinky winky" 0 1
"tinky winky" 1 2
"tinky winky" 0 3
"tinky winky" 1 4
"dipsy" 0 5
"dipsy" 1 6
"dipsy" 0 7
"dipsy" 1 8
"la la" 0 9
"la la" 1 10
"la la" 0 11
"la la" 1 12
end data.

*Produce tables.

begin program.
import spss
curs=spss.Cursor([0]) # this zero is important! It means that the values in the first column will be read as the group names on which the split is made.
group=[i[0] for i in set(curs.fetchall())]
curs.close()
for j,k in enumerate(group):
    spss.Submit("""
temp.
select if group="%s".
title "Table %s: group=%s".
CTABLES
  /VLABELS VARIABLES=gender grade DISPLAY=NAME
  /TABLE gender BY grade [S][MEAN]
  /CATEGORIES VARIABLES=gender ORDER=A KEY=VALUE EMPTY=EXCLUDE.
"""%(k,str(j+1),k))
end program.


> Date: Sun, 20 Nov 2011 10:16:27 -0800

> From: [hidden email]
> Subject: Re: syntax for repeating tables and changing title
> To: [hidden email]
>
> John,
> See !DO !DOEND to loop, to parse parallel lists see !HEAD, !TAIL
> Also, start a *NEW* topic rather than changing the subject of an existing
> topic.
> Threading goes FUBAR in Nabble archives.
> ----
> Here is a simplest possible example.
> data list free / seg x y.
> begin data
> 1 1 1 1 1 2 1 2 1 1 2 2 2 1 1 2 1 2 2 2 1 2 2 2 3 1 1 3 1 2 3 2 1
> 3 2 2
> end data.
>
> VARIABLE LEVEL x y (NOMINAL).
> DEFINE TABIT (SEGS !ENCLOSE("(",")")/ TITLES !ENCLOSE("(",")") )
> !LET !TCOPY=!TITLES
> !DO !SEG !IN (!SEGS)
> !LET !TITLE = !HEAD(!TCOPY) !LET !TCOPY = !TAIL(!TCOPY)
> TEMPORARY.
> SELECT IF (SEG = !SEG).
> CTABLES /TABLE x BY y /TITLES TITLE= !QUOTE(!TITLE).
> !DOEND .
> !ENDDEFINE.
> SET MPRINT ON.
> TABIT SEGS (1 2 3) TITLES ( A B C).
>
> In the future, Please post your attempts at any MACRO you seek assistance
> with.
> You will have to feed the parameter values to the macro rather than access
> them from the data.
> OTOH, such can be done with Python but might be a royal PITA (cursors and
> all that...)
> HTH, David
>
> J P-6 wrote:
> >
> > Good morning,
> >
> > I am having no luck trying to figure out what ought to be a doable task.
> >
> > I need to create syntax that will produce 30 CTABLES using the same
> > variables but for different subsets of data AND I would like to pass the
> > numeric increment and text from fields in the data file to the TITLE of
> > each table. I thought this can be done using a macro but I am not having
> > any luck.
> >
> > In other words, the same CTABLES would be repeated 30 times but with a
> > different title for each run.
> >
> > For example each title would read: Table 1. abcd.� to Table 30. xyz .
> > Where x = numeric id of subset and abc to xyz is text, both of which are
> > variables in the data file.
> >
> > Any advice is greatly appreciated.
> >
> > Thank you,
> > John
> >
>
>
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/data-for-analysis-tp5007085p5008550.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (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
Reply | Threaded
Open this post in threaded view
|

Re: syntax for repeating tables and changing title

J P-6
In reply to this post by Jon K Peck
Thanks for the feedback. It dawned on me that it would be far easier to use the subgroup as a split file variable (with the string modified to read more like a title) followed by some editing in word.

From: Jon K Peck <[hidden email]>
To: J P <[hidden email]>
Cc: [hidden email]
Sent: Sunday, November 20, 2011 5:06 PM
Subject: Re: [SPSSX-L] syntax for repeating tables and changing title

You would need Python code to feed data into the titling.  Sequence numbering could be done in the Python code, or you could use the SPSSINC MODIFY OUTPUT extension command to do sequence numbering in a variety of styles (even roman numerals).

To be more specific, we would need to know what the data structure is for the titling and selection parts.  That could be very easy if the data are suitable.

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        J P <[hidden email]>
To:        [hidden email]
Date:        11/20/2011 10:02 AM
Subject:        [SPSSX-L] syntax for repeating tables and changing title
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



Good morning,

I am having no luck trying to figure out what ought to be a doable task.

I need to create syntax that will produce 30 CTABLES using the same variables but for different subsets of data AND I would like to pass the numeric increment and text from fields in the data file to the TITLE of each table. I thought this can be done using a macro but I am not having any luck.

In other words, the same CTABLES would be repeated 30 times but with a different title for each run.

For example each title would read: Table 1. abcd.  to Table 30. xyz . Where x = numeric id of subset and abc to xyz is text, both of which are variables in the data file.

Any advice is greatly appreciated.

Thank you,
John