Do If Loops

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

Do If Loops

Zana Dael
I am creating a lot of variables and I usually do an "if X then Y" type
syntax or variations. And I will do this as many times as I need to
sometimes creating 100s of such variables. So I need to understand looping
and I have a case where I think it is time to begin looping.

I have an Age variable, which can be from 0 to 40. Then I want to create 40
InAge variables depending on the Age variable. Usually I do this type of
syntax:

If Age = 0 compute Age0 = 1 and so on.

Here is what I want the final file to look at.

ID   Age    Age0 Age1 Age2 Age3 Age4 Age5
1     0      1     0   0    0    0    0
1     3      0     0   0    1    0    0
1     5                               1
2     1            1
2     4                          1
3     5                               1
4     1            1
4     2               1
4     3                    1
4     4                          1


Is looping even the right approach to this problem?

Thanks

Zana

=====================
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: Do If Loops

Maguin, Eugene
Look at the Do repeat command.
Gene Maguin

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Zana Dael
Sent: Tuesday, February 18, 2014 11:49 AM
To: [hidden email]
Subject: Do If Loops

I am creating a lot of variables and I usually do an "if X then Y" type syntax or variations. And I will do this as many times as I need to sometimes creating 100s of such variables. So I need to understand looping and I have a case where I think it is time to begin looping.

I have an Age variable, which can be from 0 to 40. Then I want to create 40 InAge variables depending on the Age variable. Usually I do this type of
syntax:

If Age = 0 compute Age0 = 1 and so on.

Here is what I want the final file to look at.

ID   Age    Age0 Age1 Age2 Age3 Age4 Age5
1     0      1     0   0    0    0    0
1     3      0     0   0    1    0    0
1     5                               1
2     1            1
2     4                          1
3     5                               1
4     1            1
4     2               1
4     3                    1
4     4                          1


Is looping even the right approach to this problem?

Thanks

Zana

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Do If Loops

Zana Dael
In reply to this post by Zana Dael
Well, I wrote the following, and it seems to work, but it seems like there
has to be a simpler way.

DO REPEAT Z=Age0 to Age24.
COMPUTE Z=0.
END REPEAT.
EXECUTE.

DO REPEAT F=InAge0 to InAge24.
COMPUTE F=0.
END REPEAT.
EXECUTE.

Compute InAge1  = 1 .
Compute InAge2  = 2 .
Compute InAge3  = 3 .
Compute InAge4  = 4 .
Compute InAge5  = 5 .
Compute InAge6  = 6 .
Compute InAge7  = 7 .
Compute InAge8  = 8 .
Compute InAge9  = 9 .
Compute InAge10  = 10 .
Compute InAge11  = 11 .
Compute InAge12  = 12 .
Compute InAge13  = 13 .
Compute InAge14  = 14 .
Compute InAge15  = 15 .
Compute InAge16  = 16 .
Compute InAge17  = 17 .
Compute InAge18  = 18 .
Compute InAge19  = 19 .
Compute InAge20  = 20 .
Compute InAge21  = 21 .
Compute InAge22  = 22 .
Compute InAge23  = 23 .
Compute InAge24  = 24 .
execute.

Do REPEAT X = Age0 to Age24/ Y = InAge0 to InAge24.
If ByAge = Y X = 1.
End Repeat.
Execute.


Zana

=====================
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: Do If Loops

David Marso
Administrator
In reply to this post by Zana Dael
"Is looping even the right approach to this problem? "
No! and IMNSHO, neither is DO REPEAT.

NUMERIC age0 TO age40.
VECTOR v_age=age0 TO age40.
COMPUTE v_age(age+1)=1.
RECODE age0 TO age40 (SYSMIS=0).
--
Before posting back "what is up with age+1?" please read up on the VECTOR command.
Zd Gibbs wrote
I am creating a lot of variables and I usually do an "if X then Y" type
syntax or variations. And I will do this as many times as I need to
sometimes creating 100s of such variables. So I need to understand looping
and I have a case where I think it is time to begin looping.

I have an Age variable, which can be from 0 to 40. Then I want to create 40
InAge variables depending on the Age variable. Usually I do this type of
syntax:

If Age = 0 compute Age0 = 1 and so on.

Here is what I want the final file to look at.

ID   Age    Age0 Age1 Age2 Age3 Age4 Age5
1     0      1     0   0    0    0    0
1     3      0     0   0    1    0    0
1     5                               1
2     1            1
2     4                          1
3     5                               1
4     1            1
4     2               1
4     3                    1
4     4                          1


Is looping even the right approach to this problem?

Thanks

Zana

=====================
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
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: Do If Loops

Zana Dael
In reply to this post by Zana Dael
David,

Thank you for the syntax, it worked beautifully and I really appreciate it.
I apologize for any offense I may have engendered because I don't really
understand the tone of the email - if I am misunderstanding the tone then I
apologize again. Honestly, I wouldn't have posted what is up with age+1. I
do understand the principles behind that and many other concepts - where I
struggle is in the execution or syntax writing.

Again, I am grateful for the help.

Zana

On Tue, 18 Feb 2014 09:42:52 -0800, David Marso <[hidden email]>
wrote:

>"Is looping even the right approach to this problem? "
>No! and IMNSHO, neither is DO REPEAT.
>
>NUMERIC age0 TO age40.
>VECTOR v_age=age0 TO age40.
>COMPUTE v_age(age+1)=1.
>RECODE age0 TO age40 (SYSMIS=0).
>--
>Before posting back "what is up with age+1?" please read up on the VECTOR
>command.
>
>Zd Gibbs wrote
>> I am creating a lot of variables and I usually do an "if X then Y" type
>> syntax or variations. And I will do this as many times as I need to
>> sometimes creating 100s of such variables. So I need to understand
looping

>> and I have a case where I think it is time to begin looping.
>>
>> I have an Age variable, which can be from 0 to 40. Then I want to create
>> 40
>> InAge variables depending on the Age variable. Usually I do this type of
>> syntax:
>>
>> If Age = 0 compute Age0 = 1 and so on.
>>
>> Here is what I want the final file to look at.
>>
>> ID   Age    Age0 Age1 Age2 Age3 Age4 Age5
>> 1     0      1     0   0    0    0    0
>> 1     3      0     0   0    1    0    0
>> 1     5                               1
>> 2     1            1
>> 2     4                          1
>> 3     5                               1
>> 4     1            1
>> 4     2               1
>> 4     3                    1
>> 4     4                          1
>>
>>
>> Is looping even the right approach to this problem?
>>
>> Thanks
>>
>> Zana
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>
>> LISTSERV@.UGA
>
>>  (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
>
>
>
>
>
>-----
>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?"
>--
>View this message in context: http://spssx-
discussion.1045642.n5.nabble.com/Do-If-Loops-tp5724538p5724541.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
Reply | Threaded
Open this post in threaded view
|

Re: Do If Loops

Bruce Weaver
Administrator
In reply to this post by Zana Dael
You have a working solution from David.  But I don't recall seeing anyone ask why you want all those indicator variables for different ages.  So....why do you want all those indicator variables for different ages?  ;-)

I ask, because there may be a better method for whatever it is you want to do.

HTH.


Zana Dael wrote
I am creating a lot of variables and I usually do an "if X then Y" type
syntax or variations. And I will do this as many times as I need to
sometimes creating 100s of such variables. So I need to understand looping
and I have a case where I think it is time to begin looping.

I have an Age variable, which can be from 0 to 40. Then I want to create 40
InAge variables depending on the Age variable. Usually I do this type of
syntax:

If Age = 0 compute Age0 = 1 and so on.

Here is what I want the final file to look at.

ID   Age    Age0 Age1 Age2 Age3 Age4 Age5
1     0      1     0   0    0    0    0
1     3      0     0   0    1    0    0
1     5                               1
2     1            1
2     4                          1
3     5                               1
4     1            1
4     2               1
4     3                    1
4     4                          1


Is looping even the right approach to this problem?

Thanks

Zana

=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Do If Loops

Zana Dael
In reply to this post by Zana Dael
Bruce,

You're correct, I didn't identify why I wanted the indicator variables and I
should have. This file (and there are several others split out into groups
to make the files more manageable) includes youth and the services they
received from age 0 and above. From this particular file, it looks like 40
is the max age before they disappeared out of our systems. Part of this is
to look at outcomes, welfare use, criminal justice use, including education
and employment.  For example, one of the question(s) I am trying to answer
is:

(Binary): Did the client ever receive services  by age 5, 10, 15  . . . And
if they did receive services (by age 5, for example), were they more likely
to do better in school, or not enter the juvenile justice system or the
adult correctional system or find a job or at older ages?  If they received
services at later ages, were the less likely to continue receiving services
at older ages.

Zana


On Tue, 18 Feb 2014 10:22:31 -0800, Bruce Weaver <[hidden email]>
wrote:

>You have a working solution from David.  But I don't recall seeing anyone
ask
>why you want all those indicator variables for different ages.  So....why
do

>you want all those indicator variables for different ages?  ;-)
>
>I ask, because there may be a better method for whatever it is you want to
>do.
>
>HTH.
>
>
>
>Zana Dael wrote
>> I am creating a lot of variables and I usually do an "if X then Y" type
>> syntax or variations. And I will do this as many times as I need to
>> sometimes creating 100s of such variables. So I need to understand
looping

>> and I have a case where I think it is time to begin looping.
>>
>> I have an Age variable, which can be from 0 to 40. Then I want to create
>> 40
>> InAge variables depending on the Age variable. Usually I do this type of
>> syntax:
>>
>> If Age = 0 compute Age0 = 1 and so on.
>>
>> Here is what I want the final file to look at.
>>
>> ID   Age    Age0 Age1 Age2 Age3 Age4 Age5
>> 1     0      1     0   0    0    0    0
>> 1     3      0     0   0    1    0    0
>> 1     5                               1
>> 2     1            1
>> 2     4                          1
>> 3     5                               1
>> 4     1            1
>> 4     2               1
>> 4     3                    1
>> 4     4                          1
>>
>>
>> Is looping even the right approach to this problem?
>>
>> Thanks
>>
>> Zana
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>
>> LISTSERV@.UGA
>
>>  (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
>
>
>
>
>
>-----
>--
>Bruce Weaver
>[hidden email]
>http://sites.google.com/a/lakeheadu.ca/bweaver/
>
>"When all else fails, RTFM."
>
>NOTE: My Hotmail account is not monitored regularly.
>To send me an e-mail, please use the address shown above.
>
>--
>View this message in context: http://spssx-
discussion.1045642.n5.nabble.com/Do-If-Loops-tp5724538p5724544.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
Reply | Threaded
Open this post in threaded view
|

Re: Do If Loops

Bruce Weaver
Administrator
Thanks for providing that example of a question you need to answer.  I'm still not sure how all those indicator variables are going to help you though.  How is your data file structured?  E.g., is there one row per person, or multiple rows per person (with one per visit or something like that)?  For the sample question you gave, I wonder if you couldn't just use a series of AGGREGATES with filters turned on to limit things to records within the desired age range.

HTH.


Zana Dael wrote
Bruce,

You're correct, I didn't identify why I wanted the indicator variables and I
should have. This file (and there are several others split out into groups
to make the files more manageable) includes youth and the services they
received from age 0 and above. From this particular file, it looks like 40
is the max age before they disappeared out of our systems. Part of this is
to look at outcomes, welfare use, criminal justice use, including education
and employment.  For example, one of the question(s) I am trying to answer
is:

(Binary): Did the client ever receive services  by age 5, 10, 15  . . . And
if they did receive services (by age 5, for example), were they more likely
to do better in school, or not enter the juvenile justice system or the
adult correctional system or find a job or at older ages?  If they received
services at later ages, were the less likely to continue receiving services
at older ages.

Zana


On Tue, 18 Feb 2014 10:22:31 -0800, Bruce Weaver <[hidden email]>
wrote:

>You have a working solution from David.  But I don't recall seeing anyone
ask
>why you want all those indicator variables for different ages.  So....why
do
>you want all those indicator variables for different ages?  ;-)
>
>I ask, because there may be a better method for whatever it is you want to
>do.
>
>HTH.
>
>
>
>Zana Dael wrote
>> I am creating a lot of variables and I usually do an "if X then Y" type
>> syntax or variations. And I will do this as many times as I need to
>> sometimes creating 100s of such variables. So I need to understand
looping
>> and I have a case where I think it is time to begin looping.
>>
>> I have an Age variable, which can be from 0 to 40. Then I want to create
>> 40
>> InAge variables depending on the Age variable. Usually I do this type of
>> syntax:
>>
>> If Age = 0 compute Age0 = 1 and so on.
>>
>> Here is what I want the final file to look at.
>>
>> ID   Age    Age0 Age1 Age2 Age3 Age4 Age5
>> 1     0      1     0   0    0    0    0
>> 1     3      0     0   0    1    0    0
>> 1     5                               1
>> 2     1            1
>> 2     4                          1
>> 3     5                               1
>> 4     1            1
>> 4     2               1
>> 4     3                    1
>> 4     4                          1
>>
>>
>> Is looping even the right approach to this problem?
>>
>> Thanks
>>
>> Zana
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>
>> LISTSERV@.UGA
>
>>  (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
>
>
>
>
>
>-----
>--
>Bruce Weaver
>[hidden email]
>http://sites.google.com/a/lakeheadu.ca/bweaver/
>
>"When all else fails, RTFM."
>
>NOTE: My Hotmail account is not monitored regularly.
>To send me an e-mail, please use the address shown above.
>
>--
>View this message in context: http://spssx-
discussion.1045642.n5.nabble.com/Do-If-Loops-tp5724538p5724544.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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Do If Loops

David Marso
Administrator
Adding to Bruce's.
How does one identify a service within the data?
Doing better in school?
Being incarcerated?
Really need to have a better/more specific description picture of the input data structure and unit of observation to address the question.

Bruce Weaver wrote
Thanks for providing that example of a question you need to answer.  I'm still not sure how all those indicator variables are going to help you though.  How is your data file structured?  E.g., is there one row per person, or multiple rows per person (with one per visit or something like that)?  For the sample question you gave, I wonder if you couldn't just use a series of AGGREGATES with filters turned on to limit things to records within the desired age range.

HTH.


Zana Dael wrote
Bruce,

You're correct, I didn't identify why I wanted the indicator variables and I
should have. This file (and there are several others split out into groups
to make the files more manageable) includes youth and the services they
received from age 0 and above. From this particular file, it looks like 40
is the max age before they disappeared out of our systems. Part of this is
to look at outcomes, welfare use, criminal justice use, including education
and employment.  For example, one of the question(s) I am trying to answer
is:

(Binary): Did the client ever receive services  by age 5, 10, 15  . . . And
if they did receive services (by age 5, for example), were they more likely
to do better in school, or not enter the juvenile justice system or the
adult correctional system or find a job or at older ages?  If they received
services at later ages, were the less likely to continue receiving services
at older ages.

Zana


On Tue, 18 Feb 2014 10:22:31 -0800, Bruce Weaver <[hidden email]>
wrote:

>You have a working solution from David.  But I don't recall seeing anyone
ask
>why you want all those indicator variables for different ages.  So....why
do
>you want all those indicator variables for different ages?  ;-)
>
>I ask, because there may be a better method for whatever it is you want to
>do.
>
>HTH.
>
>
>
>Zana Dael wrote
>> I am creating a lot of variables and I usually do an "if X then Y" type
>> syntax or variations. And I will do this as many times as I need to
>> sometimes creating 100s of such variables. So I need to understand
looping
>> and I have a case where I think it is time to begin looping.
>>
>> I have an Age variable, which can be from 0 to 40. Then I want to create
>> 40
>> InAge variables depending on the Age variable. Usually I do this type of
>> syntax:
>>
>> If Age = 0 compute Age0 = 1 and so on.
>>
>> Here is what I want the final file to look at.
>>
>> ID   Age    Age0 Age1 Age2 Age3 Age4 Age5
>> 1     0      1     0   0    0    0    0
>> 1     3      0     0   0    1    0    0
>> 1     5                               1
>> 2     1            1
>> 2     4                          1
>> 3     5                               1
>> 4     1            1
>> 4     2               1
>> 4     3                    1
>> 4     4                          1
>>
>>
>> Is looping even the right approach to this problem?
>>
>> Thanks
>>
>> Zana
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>
>> LISTSERV@.UGA
>
>>  (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
>
>
>
>
>
>-----
>--
>Bruce Weaver
>[hidden email]
>http://sites.google.com/a/lakeheadu.ca/bweaver/
>
>"When all else fails, RTFM."
>
>NOTE: My Hotmail account is not monitored regularly.
>To send me an e-mail, please use the address shown above.
>
>--
>View this message in context: http://spssx-
discussion.1045642.n5.nabble.com/Do-If-Loops-tp5724538p5724544.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
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: Do If Loops

Zana Dael
In reply to this post by Zana Dael
Well, we have a lot of data from twelve different systems, including
welfare, housing, criminal justice, family, court, education, employment.
All of files are in the long format and we use aggregate variables with
filtering variables for many indicators. Services are marked by flags
indicating what they are, such as Medical Assistance, housing support, etc.
School includes test scores at specific ages and graduation rates.
Employment includes job and wage rates. Things like incarceration and
probation are start and end dates and the jurisdiction that is holding the
person, jail, prison, detention, etc. Right now we each have a chunk and are
creating variables, which is probably inefficient, but it is a lot of
overwhelming data to get our arms around.

The thing with the ages is, some of the project sponsors want to know: if
ever and how many, services were experienced by certain ages. Thus, if a
youth had seventeen services by age 7, did that have any impact on their
education, criminal justice involvement or employment outcomes. The argument
is that some of these services can be stabilizing, such as food and housing
and may improve education outcomes, or not. . . haven't got that far.

Zana


On Tue, 18 Feb 2014 12:37:13 -0800, David Marso <[hidden email]>
wrote:

>Adding to Bruce's.
>How does one identify a service within the data?
>Doing better in school?
>Being incarcerated?
>Really need to have a better/more specific description picture of the input
>data structure and unit of observation to address the question.
>
>
>Bruce Weaver wrote
>> Thanks for providing that example of a question you need to answer.  I'm
>> still not sure how all those indicator variables are going to help you
>> though.  How is your data file structured?  E.g., is there one row per
>> person, or multiple rows per person (with one per visit or something like
>> that)?  For the sample question you gave, I wonder if you couldn't just
>> use a series of AGGREGATES with filters turned on to limit things to
>> records within the desired age range.
>>
>> HTH.
>>
>> Zana Dael wrote
>>> Bruce,
>>>
>>> You're correct, I didn't identify why I wanted the indicator variables
>>> and I
>>> should have. This file (and there are several others split out into
>>> groups
>>> to make the files more manageable) includes youth and the services they
>>> received from age 0 and above. From this particular file, it looks like
>>> 40
>>> is the max age before they disappeared out of our systems. Part of this
>>> is
>>> to look at outcomes, welfare use, criminal justice use, including
>>> education
>>> and employment.  For example, one of the question(s) I am trying to
>>> answer
>>> is:
>>>
>>> (Binary): Did the client ever receive services  by age 5, 10, 15  . . .
>>> And
>>> if they did receive services (by age 5, for example), were they more
>>> likely
>>> to do better in school, or not enter the juvenile justice system or the
>>> adult correctional system or find a job or at older ages?  If they
>>> received
>>> services at later ages, were the less likely to continue receiving
>>> services
>>> at older ages.
>>>
>>> Zana
>>>
>>>
>>> On Tue, 18 Feb 2014 10:22:31 -0800, Bruce Weaver &lt;
>
>>> bruce.weaver@
>
>>> &gt;
>>> wrote:
>>>
>>>>You have a working solution from David.  But I don't recall seeing
anyone
>>> ask
>>>>why you want all those indicator variables for different ages.
So....why

>>> do
>>>>you want all those indicator variables for different ages?  ;-)
>>>>
>>>>I ask, because there may be a better method for whatever it is you want
>to
>>>>do.
>>>>
>>>>HTH.
>>>>
>>>>
>>>>
>>>>Zana Dael wrote
>>>>> I am creating a lot of variables and I usually do an "if X then Y"
type

>>>>> syntax or variations. And I will do this as many times as I need to
>>>>> sometimes creating 100s of such variables. So I need to understand
>>> looping
>>>>> and I have a case where I think it is time to begin looping.
>>>>>
>>>>> I have an Age variable, which can be from 0 to 40. Then I want to
>>>>> create
>>>>> 40
>>>>> InAge variables depending on the Age variable. Usually I do this type
>>>>> of
>>>>> syntax:
>>>>>
>>>>> If Age = 0 compute Age0 = 1 and so on.
>>>>>
>>>>> Here is what I want the final file to look at.
>>>>>
>>>>> ID   Age    Age0 Age1 Age2 Age3 Age4 Age5
>>>>> 1     0      1     0   0    0    0    0
>>>>> 1     3      0     0   0    1    0    0
>>>>> 1     5                               1
>>>>> 2     1            1
>>>>> 2     4                          1
>>>>> 3     5                               1
>>>>> 4     1            1
>>>>> 4     2               1
>>>>> 4     3                    1
>>>>> 4     4                          1
>>>>>
>>>>>
>>>>> Is looping even the right approach to this problem?
>>>>>
>>>>> Thanks
>>>>>
>>>>> Zana
>>>>>
>>>>> =====================
>>>>> To manage your subscription to SPSSX-L, send a message to
>>>>
>>>>> LISTSERV@.UGA
>>>>
>>>>>  (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
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>-----
>>>>--
>>>>Bruce Weaver
>>>>
>
>>> bweaver@
>
>>>>http://sites.google.com/a/lakeheadu.ca/bweaver/
>>>>
>>>>"When all else fails, RTFM."
>>>>
>>>>NOTE: My Hotmail account is not monitored regularly.
>>>>To send me an e-mail, please use the address shown above.
>>>>
>>>>--
>>>>View this message in context: http://spssx-
>>> discussion.1045642.n5.nabble.com/Do-If-Loops-tp5724538p5724544.html
>>>>Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>>>>
>>>>=====================
>>>>To manage your subscription to SPSSX-L, send a message to
>>>>
>
>>> LISTSERV@.UGA
>
>>>  (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
>
>>> LISTSERV@.UGA
>
>>>  (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
>
>
>
>
>
>-----
>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?"
>--
>View this message in context: http://spssx-
discussion.1045642.n5.nabble.com/Do-If-Loops-tp5724538p5724551.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
Reply | Threaded
Open this post in threaded view
|

Re: Do If Loops

David Marso
Administrator
So looking ahead, how are these age dummy variables playing a role in addressing these questions?

Zana Dael wrote
Well, we have a lot of data from twelve different systems, including
welfare, housing, criminal justice, family, court, education, employment.
All of files are in the long format and we use aggregate variables with
filtering variables for many indicators. Services are marked by flags
indicating what they are, such as Medical Assistance, housing support, etc.
School includes test scores at specific ages and graduation rates.
Employment includes job and wage rates. Things like incarceration and
probation are start and end dates and the jurisdiction that is holding the
person, jail, prison, detention, etc. Right now we each have a chunk and are
creating variables, which is probably inefficient, but it is a lot of
overwhelming data to get our arms around.

The thing with the ages is, some of the project sponsors want to know: if
ever and how many, services were experienced by certain ages. Thus, if a
youth had seventeen services by age 7, did that have any impact on their
education, criminal justice involvement or employment outcomes. The argument
is that some of these services can be stabilizing, such as food and housing
and may improve education outcomes, or not. . . haven't got that far.

Zana


On Tue, 18 Feb 2014 12:37:13 -0800, David Marso <[hidden email]>
wrote:

>Adding to Bruce's.
>How does one identify a service within the data?
>Doing better in school?
>Being incarcerated?
>Really need to have a better/more specific description picture of the input
>data structure and unit of observation to address the question.
>
>
>Bruce Weaver wrote
>> Thanks for providing that example of a question you need to answer.  I'm
>> still not sure how all those indicator variables are going to help you
>> though.  How is your data file structured?  E.g., is there one row per
>> person, or multiple rows per person (with one per visit or something like
>> that)?  For the sample question you gave, I wonder if you couldn't just
>> use a series of AGGREGATES with filters turned on to limit things to
>> records within the desired age range.
>>
>> HTH.
>>
>> Zana Dael wrote
>>> Bruce,
>>>
>>> You're correct, I didn't identify why I wanted the indicator variables
>>> and I
>>> should have. This file (and there are several others split out into
>>> groups
>>> to make the files more manageable) includes youth and the services they
>>> received from age 0 and above. From this particular file, it looks like
>>> 40
>>> is the max age before they disappeared out of our systems. Part of this
>>> is
>>> to look at outcomes, welfare use, criminal justice use, including
>>> education
>>> and employment.  For example, one of the question(s) I am trying to
>>> answer
>>> is:
>>>
>>> (Binary): Did the client ever receive services  by age 5, 10, 15  . . .
>>> And
>>> if they did receive services (by age 5, for example), were they more
>>> likely
>>> to do better in school, or not enter the juvenile justice system or the
>>> adult correctional system or find a job or at older ages?  If they
>>> received
>>> services at later ages, were the less likely to continue receiving
>>> services
>>> at older ages.
>>>
>>> Zana
>>>
>>>
>>> On Tue, 18 Feb 2014 10:22:31 -0800, Bruce Weaver <
>
>>> bruce.weaver@
>
>>> >
>>> wrote:
>>>
>>>>You have a working solution from David.  But I don't recall seeing
anyone
>>> ask
>>>>why you want all those indicator variables for different ages.
So....why
>>> do
>>>>you want all those indicator variables for different ages?  ;-)
>>>>
>>>>I ask, because there may be a better method for whatever it is you want
>to
>>>>do.
>>>>
>>>>HTH.
>>>>
>>>>
>>>>
>>>>Zana Dael wrote
>>>>> I am creating a lot of variables and I usually do an "if X then Y"
type
>>>>> syntax or variations. And I will do this as many times as I need to
>>>>> sometimes creating 100s of such variables. So I need to understand
>>> looping
>>>>> and I have a case where I think it is time to begin looping.
>>>>>
>>>>> I have an Age variable, which can be from 0 to 40. Then I want to
>>>>> create
>>>>> 40
>>>>> InAge variables depending on the Age variable. Usually I do this type
>>>>> of
>>>>> syntax:
>>>>>
>>>>> If Age = 0 compute Age0 = 1 and so on.
>>>>>
>>>>> Here is what I want the final file to look at.
>>>>>
>>>>> ID   Age    Age0 Age1 Age2 Age3 Age4 Age5
>>>>> 1     0      1     0   0    0    0    0
>>>>> 1     3      0     0   0    1    0    0
>>>>> 1     5                               1
>>>>> 2     1            1
>>>>> 2     4                          1
>>>>> 3     5                               1
>>>>> 4     1            1
>>>>> 4     2               1
>>>>> 4     3                    1
>>>>> 4     4                          1
>>>>>
>>>>>
>>>>> Is looping even the right approach to this problem?
>>>>>
>>>>> Thanks
>>>>>
>>>>> Zana
>>>>>
>>>>> =====================
>>>>> To manage your subscription to SPSSX-L, send a message to
>>>>
>>>>> LISTSERV@.UGA
>>>>
>>>>>  (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
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>-----
>>>>--
>>>>Bruce Weaver
>>>>
>
>>> bweaver@
>
>>>>http://sites.google.com/a/lakeheadu.ca/bweaver/
>>>>
>>>>"When all else fails, RTFM."
>>>>
>>>>NOTE: My Hotmail account is not monitored regularly.
>>>>To send me an e-mail, please use the address shown above.
>>>>
>>>>--
>>>>View this message in context: http://spssx-
>>> discussion.1045642.n5.nabble.com/Do-If-Loops-tp5724538p5724544.html
>>>>Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>>>>
>>>>=====================
>>>>To manage your subscription to SPSSX-L, send a message to
>>>>
>
>>> LISTSERV@.UGA
>
>>>  (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
>
>>> LISTSERV@.UGA
>
>>>  (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
>
>
>
>
>
>-----
>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?"
>--
>View this message in context: http://spssx-
discussion.1045642.n5.nabble.com/Do-If-Loops-tp5724538p5724551.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
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: Do If Loops

Ntonghanwah Forcheh
In reply to this post by Zana Dael
Hi Dael,

If you have not got a satisfactory ans to your problem
the following will help.
I have computed Age0 outside the loop since default counting for vectors starts from 1.



DATA LIST FREE
  /ID  (F1.0)
  Age (F1.0).
BEGIN DATA
1 0
1 3
1 5
2 1
2 4
3 5
4 1
4 2
4 3
4 4
END DATA.
EXECUTE.

**
** if ages range from say 0 to 99, change the value 5 to 99 on both the VECTOR and DO REPEAT lines.
*** The logical compute returns 1 if true and 0 if false. If you wish to have missing values instead, 
*** replace COMPUTE command with IF  command as in   IF  (Age = #i) Age_(#i)  = #i.

COMPUTE Age0 = (Age=0).
FORMATS Age0 (f1).

VECTOR  Age_(5, F1).
DO REPEAT #i = 1 TO 5.
        COMPUTE Age_(#i)  =  (Age = #i)  .
    END REPEAT.
 EXECUTE.


On Tue, Feb 18, 2014 at 6:48 PM, Zana Dael <[hidden email]> wrote:
I am creating a lot of variables and I usually do an "if X then Y" type
syntax or variations. And I will do this as many times as I need to
sometimes creating 100s of such variables. So I need to understand looping
and I have a case where I think it is time to begin looping.

I have an Age variable, which can be from 0 to 40. Then I want to create 40
InAge variables depending on the Age variable. Usually I do this type of
syntax:

If Age = 0 compute Age0 = 1 and so on.

Here is what I want the final file to look at.

ID   Age    Age0 Age1 Age2 Age3 Age4 Age5
1     0      1     0   0    0    0    0
1     3      0     0   0    1    0    0
1     5                               1
2     1            1
2     4                          1
3     5                               1
4     1            1
4     2               1
4     3                    1
4     4                          1


Is looping even the right approach to this problem?

Thanks

Zana

=====================
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



--
Professor Ntonghanwah Forcheh
Department of Statistics,
University of Botswana
Private Bag UB00705, Gaborone, Botswana.
Office: <a href="tel:%2B267%20355%202696" value="+2673552696" target="_blank">+267 355 2696,
 Mobile:  Orange <a href="tel:%2B267%2075%2026%202963" value="+26775262963" target="_blank">+267 75 26 2963,    Bmobile:  73181378:    Mascom  754 21238
fax: <a href="tel:%2B267%203185099" value="+2673185099" target="_blank">+267 3185099;
Alternative Email: [hidden email]
*@Honesty is a Virtue, Freedom of the Mind is Power.
Motto: Never be afraid to be honest, Never lie to yourself, Trust in the
Truth and you will be forever free.*


Reply | Threaded
Open this post in threaded view
|

Re: Do If Loops

Ntonghanwah Forcheh
Please note small error on the last line of comment on last posting

*
*** replace COMPUTE command with IF  command as in   IF  (Age = #i) Age_(#i)  = #i
should be

*** replace COMPUTE command with IF  command as in   IF  (Age = #i) Age_(#i)  = 1.


On Wed, Feb 19, 2014 at 8:24 AM, Ntonghanwah Forcheh <[hidden email]> wrote:
Hi Dael,

If you have not got a satisfactory ans to your problem
the following will help.
I have computed Age0 outside the loop since default counting for vectors starts from 1.



DATA LIST FREE
  /ID  (F1.0)
  Age (F1.0).
BEGIN DATA
1 0
1 3
1 5
2 1
2 4
3 5
4 1
4 2
4 3
4 4
END DATA.
EXECUTE.

**
** if ages range from say 0 to 99, change the value 5 to 99 on both the VECTOR and DO REPEAT lines.
*** The logical compute returns 1 if true and 0 if false. If you wish to have missing values instead, 
*** replace COMPUTE command with IF  command as in   IF  (Age = #i) Age_(#i)  = #i.

COMPUTE Age0 = (Age=0).
FORMATS Age0 (f1).

VECTOR  Age_(5, F1).
DO REPEAT #i = 1 TO 5.
        COMPUTE Age_(#i)  =  (Age = #i)  .
    END REPEAT.
 EXECUTE.


On Tue, Feb 18, 2014 at 6:48 PM, Zana Dael <[hidden email]> wrote:
I am creating a lot of variables and I usually do an "if X then Y" type
syntax or variations. And I will do this as many times as I need to
sometimes creating 100s of such variables. So I need to understand looping
and I have a case where I think it is time to begin looping.

I have an Age variable, which can be from 0 to 40. Then I want to create 40
InAge variables depending on the Age variable. Usually I do this type of
syntax:

If Age = 0 compute Age0 = 1 and so on.

Here is what I want the final file to look at.

ID   Age    Age0 Age1 Age2 Age3 Age4 Age5
1     0      1     0   0    0    0    0
1     3      0     0   0    1    0    0
1     5                               1
2     1            1
2     4                          1
3     5                               1
4     1            1
4     2               1
4     3                    1
4     4                          1


Is looping even the right approach to this problem?

Thanks

Zana

=====================
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



--
Professor Ntonghanwah Forcheh
Department of Statistics,
University of Botswana
Private Bag UB00705, Gaborone, Botswana.
Office: <a href="tel:%2B267%20355%202696" value="+2673552696" target="_blank">+267 355 2696,
 Mobile:  Orange <a href="tel:%2B267%2075%2026%202963" value="+26775262963" target="_blank">+267 75 26 2963,    Bmobile:  73181378:    Mascom  754 21238
fax: <a href="tel:%2B267%203185099" value="+2673185099" target="_blank">+267 3185099;
Alternative Email: [hidden email]
*@Honesty is a Virtue, Freedom of the Mind is Power.
Motto: Never be afraid to be honest, Never lie to yourself, Trust in the
Truth and you will be forever free.*





--
Professor Ntonghanwah Forcheh
Department of Statistics,
University of Botswana
Private Bag UB00705, Gaborone, Botswana.
Office: +267 355 2696,
 Mobile:  Orange +267 75 26 2963,    Bmobile:  73181378:    Mascom  754 21238
fax: +267 3185099;
Alternative Email: [hidden email]
*@Honesty is a Virtue, Freedom of the Mind is Power.
Motto: Never be afraid to be honest, Never lie to yourself, Trust in the
Truth and you will be forever free.*


Reply | Threaded
Open this post in threaded view
|

Re: Do If Loops

David Marso
Administrator
No need for a loop / DO REPEAT here at all. See my solution from yesterday!

Ntonghanwah Forcheh wrote
Please note small error on the last line of comment on last posting

*
*** replace COMPUTE command with IF  command as in   IF  (Age = #i)
Age_(#i)  = #i
should be

*** replace COMPUTE command with IF  command as in   IF  (Age = #i)
Age_(#i)  = 1.


On Wed, Feb 19, 2014 at 8:24 AM, Ntonghanwah Forcheh <[hidden email]>wrote:

> Hi Dael,
>
> If you have not got a satisfactory ans to your problem
> the following will help.
> I have computed Age0 outside the loop since default counting for vectors
> starts from 1.
>
>
>
> DATA LIST FREE
>   /ID  (F1.0)
>   Age (F1.0).
> BEGIN DATA
> 1 0
> 1 3
> 1 5
> 2 1
> 2 4
> 3 5
> 4 1
> 4 2
> 4 3
> 4 4
> END DATA.
> EXECUTE.
>
> **
> ** if ages range from say 0 to 99, change the value 5 to 99 on both the
> VECTOR and DO REPEAT lines.
> *** The logical compute returns 1 if true and 0 if false. If you wish to
> have missing values instead,
> *** replace COMPUTE command with IF  command as in   IF  (Age = #i)
> Age_(#i)  = #i.
>
> COMPUTE Age0 = (Age=0).
> FORMATS Age0 (f1).
>
> VECTOR  Age_(5, F1).
> DO REPEAT #i = 1 TO 5.
>         COMPUTE Age_(#i)  =  (Age = #i)  .
>     END REPEAT.
>  EXECUTE.
>
>
> On Tue, Feb 18, 2014 at 6:48 PM, Zana Dael <[hidden email]> wrote:
>
>> I am creating a lot of variables and I usually do an "if X then Y" type
>> syntax or variations. And I will do this as many times as I need to
>> sometimes creating 100s of such variables. So I need to understand looping
>> and I have a case where I think it is time to begin looping.
>>
>> I have an Age variable, which can be from 0 to 40. Then I want to create
>> 40
>> InAge variables depending on the Age variable. Usually I do this type of
>> syntax:
>>
>> If Age = 0 compute Age0 = 1 and so on.
>>
>> Here is what I want the final file to look at.
>>
>> ID   Age    Age0 Age1 Age2 Age3 Age4 Age5
>> 1     0      1     0   0    0    0    0
>> 1     3      0     0   0    1    0    0
>> 1     5                               1
>> 2     1            1
>> 2     4                          1
>> 3     5                               1
>> 4     1            1
>> 4     2               1
>> 4     3                    1
>> 4     4                          1
>>
>>
>> Is looping even the right approach to this problem?
>>
>> Thanks
>>
>> Zana
>>
>> =====================
>> 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
>>
>
>
>
> --
> Professor Ntonghanwah Forcheh
> Department of Statistics,
> University of Botswana
> Private Bag UB00705, Gaborone, Botswana.
> Office: +267 355 2696,
>  Mobile:  Orange +267 75 26 2963,    Bmobile:  73181378:    Mascom  754
> 21238
> fax: +267 3185099;
> Alternative Email: [hidden email]
> *@Honesty is a Virtue, Freedom of the Mind is Power.
> Motto: Never be afraid to be honest, Never lie to yourself, Trust in the
> Truth and you will be forever free.*
>
>
>


--
Professor Ntonghanwah Forcheh
Department of Statistics,
University of Botswana
Private Bag UB00705, Gaborone, Botswana.
Office: +267 355 2696,
 Mobile:  Orange +267 75 26 2963,    Bmobile:  73181378:    Mascom  754
21238
fax: +267 3185099;
Alternative Email: [hidden email]
*@Honesty is a Virtue, Freedom of the Mind is Power.
Motto: Never be afraid to be honest, Never lie to yourself, Trust in the
Truth and you will be forever free.*
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: Do If Loops

Richard Ristow
In reply to this post by Zana Dael
At 05:11 PM 2/18/2014, Zana Dael wrote:

>We have a lot of data from twelve different systems, including
>welfare, housing, criminal justice, family, court, education,
>employment. All of files are in the long format and we use aggregate
>variables with filtering variables for many indicators. Services are
>marked by flags indicating what they are, such as Medical
>Assistance, housing support, etc. School includes test scores at
>specific ages and graduation rates. Employment includes job and wage
>rates. Things like incarceration and probation are start and end
>dates and the jurisdiction that is holding the person, jail, prison,
>detention, etc.

I'd consider building a unified, long-form file in which each record
is an 'event', identified by the ID of the person and the date of the
event. (You may want to add a one-character field that's "A", "B",
etc., to distinguish multiple events that fall on the same date.)

So, what's an 'event'? Any of the things you've listed, e.g. service
provided, court appearance, ...  Every event record should have what
happened on that date, and enough identifying information (agency
name, or whatever) to trace it back to its source.

Things that happen over time, like incarceration or enrollment in
school, should be separated into TWO 'event' records, one for the
start of the period and one for the end. (However, the end date
should be kept on the start record, and the start date on the end
record; these should just not be the *key* dates on those records.)

You'll probably want to use MATCH FILES, or something similar, to put
basic demographic information -- gender, birth date -- on every event record.

And you may want to generate 'event' records for dates, such as the
7th birthday, that are meaningful for your analysis whether or not
any agency reported something happening that day.

>The thing with the ages is, some of the project sponsors want to
>know: if ever and how many, services were experienced by certain
>ages. Thus, if a youth had seventeen services by age 7, did that
>have any impact on their education, criminal justice involvement or
>employment outcomes.

Starting with the file as I've described it, sorted by person and
date, you can write transformation code (using LAG and LEAVE) to add
information like,
. Number of services, or services of a certain kind, received on and
before the date
. Whether incarcerated, in school, etc., on that date -- based on the
beginning of the incarceration, or whatever, having come earlier, and
the end not yet reached.

Do that, then select out records for the 7th birthday, and you have
the count of services you're looking for.

=====================
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: Do If Loops

Zana Dael
In reply to this post by Zana Dael
Wow, I don't know where to begin. This is an amazing amount of help. I can't
tell you all how much I appreciate all of the guidance in this email string.
There is a lot here I haven't even thought about and now I'm ahead in this
project because now there are some procedures I can follow. After running
through everything said, I think I'm confident I can handle all the
suggestions.

Again, you all provided so much more than my original request. Thanks
everyone. This will help me more than you know.

Zana



On Wed, 19 Feb 2014 13:17:17 -0500, Richard Ristow <[hidden email]>
wrote:

>At 05:11 PM 2/18/2014, Zana Dael wrote:
>
>>We have a lot of data from twelve different systems, including
>>welfare, housing, criminal justice, family, court, education,
>>employment. All of files are in the long format and we use aggregate
>>variables with filtering variables for many indicators. Services are
>>marked by flags indicating what they are, such as Medical
>>Assistance, housing support, etc. School includes test scores at
>>specific ages and graduation rates. Employment includes job and wage
>>rates. Things like incarceration and probation are start and end
>>dates and the jurisdiction that is holding the person, jail, prison,
>>detention, etc.
>
>I'd consider building a unified, long-form file in which each record
>is an 'event', identified by the ID of the person and the date of the
>event. (You may want to add a one-character field that's "A", "B",
>etc., to distinguish multiple events that fall on the same date.)
>
>So, what's an 'event'? Any of the things you've listed, e.g. service
>provided, court appearance, ...  Every event record should have what
>happened on that date, and enough identifying information (agency
>name, or whatever) to trace it back to its source.
>
>Things that happen over time, like incarceration or enrollment in
>school, should be separated into TWO 'event' records, one for the
>start of the period and one for the end. (However, the end date
>should be kept on the start record, and the start date on the end
>record; these should just not be the *key* dates on those records.)
>
>You'll probably want to use MATCH FILES, or something similar, to put
>basic demographic information -- gender, birth date -- on every event
record.

>
>And you may want to generate 'event' records for dates, such as the
>7th birthday, that are meaningful for your analysis whether or not
>any agency reported something happening that day.
>
>>The thing with the ages is, some of the project sponsors want to
>>know: if ever and how many, services were experienced by certain
>>ages. Thus, if a youth had seventeen services by age 7, did that
>>have any impact on their education, criminal justice involvement or
>>employment outcomes.
>
>Starting with the file as I've described it, sorted by person and
>date, you can write transformation code (using LAG and LEAVE) to add
>information like,
>. Number of services, or services of a certain kind, received on and
>before the date
>. Whether incarcerated, in school, etc., on that date -- based on the
>beginning of the incarceration, or whatever, having come earlier, and
>the end not yet reached.
>
>Do that, then select out records for the 7th birthday, and you have
>the count of services you're looking for.
>
>=====================
>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
Reply | Threaded
Open this post in threaded view
|

Re: Do If Loops

David Marso
Administrator
In addition to Richard's sage advice re Long (normalized) format I urge.
1. Do pay careful attention to creating a consistent ID/Lookup key for joining the diverse files.
2. Take time to master the following SPSS commands (you will need them).
  MATCH FILES/ADD FILES
  AGGREGATE
  VARSTOCASES/CASESTOVARS
  VECTOR/LOOP/XSAVE
  Look through al of the functions available in COMPUTE command
  Review the Universals section (at the beginning of the syntax reference).
3. Inventory the set of tasks in the pipeline and think through ALL of  the variables and processes you will require to fulfill them.  Create a roadmap.

Zana Dael wrote
Wow, I don't know where to begin. This is an amazing amount of help. I can't
tell you all how much I appreciate all of the guidance in this email string.
There is a lot here I haven't even thought about and now I'm ahead in this
project because now there are some procedures I can follow. After running
through everything said, I think I'm confident I can handle all the
suggestions.

Again, you all provided so much more than my original request. Thanks
everyone. This will help me more than you know.

Zana



On Wed, 19 Feb 2014 13:17:17 -0500, Richard Ristow <[hidden email]>
wrote:

>At 05:11 PM 2/18/2014, Zana Dael wrote:
>
>>We have a lot of data from twelve different systems, including
>>welfare, housing, criminal justice, family, court, education,
>>employment. All of files are in the long format and we use aggregate
>>variables with filtering variables for many indicators. Services are
>>marked by flags indicating what they are, such as Medical
>>Assistance, housing support, etc. School includes test scores at
>>specific ages and graduation rates. Employment includes job and wage
>>rates. Things like incarceration and probation are start and end
>>dates and the jurisdiction that is holding the person, jail, prison,
>>detention, etc.
>
>I'd consider building a unified, long-form file in which each record
>is an 'event', identified by the ID of the person and the date of the
>event. (You may want to add a one-character field that's "A", "B",
>etc., to distinguish multiple events that fall on the same date.)
>
>So, what's an 'event'? Any of the things you've listed, e.g. service
>provided, court appearance, ...  Every event record should have what
>happened on that date, and enough identifying information (agency
>name, or whatever) to trace it back to its source.
>
>Things that happen over time, like incarceration or enrollment in
>school, should be separated into TWO 'event' records, one for the
>start of the period and one for the end. (However, the end date
>should be kept on the start record, and the start date on the end
>record; these should just not be the *key* dates on those records.)
>
>You'll probably want to use MATCH FILES, or something similar, to put
>basic demographic information -- gender, birth date -- on every event
record.
>
>And you may want to generate 'event' records for dates, such as the
>7th birthday, that are meaningful for your analysis whether or not
>any agency reported something happening that day.
>
>>The thing with the ages is, some of the project sponsors want to
>>know: if ever and how many, services were experienced by certain
>>ages. Thus, if a youth had seventeen services by age 7, did that
>>have any impact on their education, criminal justice involvement or
>>employment outcomes.
>
>Starting with the file as I've described it, sorted by person and
>date, you can write transformation code (using LAG and LEAVE) to add
>information like,
>. Number of services, or services of a certain kind, received on and
>before the date
>. Whether incarcerated, in school, etc., on that date -- based on the
>beginning of the incarceration, or whatever, having come earlier, and
>the end not yet reached.
>
>Do that, then select out records for the 7th birthday, and you have
>the count of services you're looking for.
>
>=====================
>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
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?"