creating a new variable from a series of variables

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

creating a new variable from a series of variables

Greg
Hi everyone,

I have a dataset that looks like this:

region  cceduclhs  cceduchs  cceducsomecoll  cceduccollege
 1         8405 4239      5007                 4784
 2          2888       1640            2312                 1638

The above units except for the region variable are individuals. For example, for cceduclhs in region 1, we have 8,405 individuals with less than a high school diploma.

I want to recode the above variables, except region, into an ordinal that hopefully will look like this:

cceduc
lhs=1
hs=2
some college=3
college=4

Any suggestions would be greatly appreciated! I can definitely provide more info if the above question doesn't make sense.

Regards,
Greg
Reply | Threaded
Open this post in threaded view
|

Re: creating a new variable from a series of variables

Art Kendall
What values do you have in your 4 original variables?
Open a new instance of SPSS.  Copy the syntax below to a syntax file.
Click <run>. Click <all>.
Is this what you are looking for?

data list list /id (f3)
  region  cceduclhs  cceduchs  cceducsomecoll  cceduccollege (5f1).
begin data
1 1 0 0 0 1
2 1 0 0 1 0
3 1 0 1 0 0
4 1 1 0 0 0
4 1 1 1 0 0
5 1 0 0 1 1
6 2 0 0 0 1
7 2 0 0 1 0
8 2 0 1 0 0
9 2 1 0 0 0
10 2 1 1 0 0
11 2 0 0 1 1
end data.
numeric cceduc (f1).
compute cceduc = 0.
value labels cceduc
 0 'not found'
 1 'lhs'
 2 'hs'
 3 'some college'
 4 'college'/.
* find highest level flagged'.
do repeat flag = cceduclhs  cceduchs  cceducsomecoll  cceduccollege/
  callit = 1 to 4.
if flag eq 1 cceduc = callit.
end repeat.
LIST .

Art Kendall
Social Research Consultants

grigoris wrote:

> Hi everyone,
>
> I have a dataset that looks like this:
>
> region  cceduclhs  cceduchs  cceducsomecoll  cceduccollege
>  1         8405  4239         5007                       4784
>  2          2888       1640            2312                 1638
>
> The above units except for the region variable are individuals. For example,
> for cceduclhs in region 1, we have 8,405 individuals with less than a high
> school diploma.
>
> I want to recode the above variables, except region, into an ordinal that
> hopefully will look like this:
>
> cceduc
> lhs=1
> hs=2
> some college=3
> college=4
>
> Any suggestions would be greatly appreciated! I can definitely provide more
> info if the above question doesn't make sense.
>
> Regards,
> Greg
> --
> View this message in context: http://www.nabble.com/creating-a-new-variable-from-a-series-of-variables-tp23361101p23361101.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
|

Re: creating a new variable from a series of variables

Greg
I appreciate your response, thank you.
The original file was an individual data file in which educational attainment was coded as an ordinal variable (less than high school, high school, some college, college+). So the original values were as follows:

Less than high school: 1
High school: 2
Some college: 3
College+:4

In the original file, I created a variable differentiating between central-city & suburb education attainment.  I then used COUNT to count the number of individuals in each category. This gave me a series of dummy variables (cceduclhs, cceduchs, cceducsomecollege, cceduccollege, outeduclhs, outeduchs, outeducsomecollege, outeduccollege). By this I was able to get the number of individuals in each category.
Afterwards, I aggregated the file, using region as the break variable and summing all the above variables, which gave me the file i posted earlier.

Thanks,
Greg  

Art Kendall wrote
What values do you have in your 4 original variables?
Open a new instance of SPSS.  Copy the syntax below to a syntax file.
Click <run>. Click <all>.
Is this what you are looking for?

data list list /id (f3)
  region  cceduclhs  cceduchs  cceducsomecoll  cceduccollege (5f1).
begin data
1 1 0 0 0 1
2 1 0 0 1 0
3 1 0 1 0 0
4 1 1 0 0 0
4 1 1 1 0 0
5 1 0 0 1 1
6 2 0 0 0 1
7 2 0 0 1 0
8 2 0 1 0 0
9 2 1 0 0 0
10 2 1 1 0 0
11 2 0 0 1 1
end data.
numeric cceduc (f1).
compute cceduc = 0.
value labels cceduc
 0 'not found'
 1 'lhs'
 2 'hs'
 3 'some college'
 4 'college'/.
* find highest level flagged'.
do repeat flag = cceduclhs  cceduchs  cceducsomecoll  cceduccollege/
  callit = 1 to 4.
if flag eq 1 cceduc = callit.
end repeat.
LIST .

Art Kendall
Social Research Consultants

grigoris wrote:
> Hi everyone,
>
> I have a dataset that looks like this:
>
> region  cceduclhs  cceduchs  cceducsomecoll  cceduccollege
>  1         8405  4239         5007                       4784
>  2          2888       1640            2312                 1638
>
> The above units except for the region variable are individuals. For example,
> for cceduclhs in region 1, we have 8,405 individuals with less than a high
> school diploma.
>
> I want to recode the above variables, except region, into an ordinal that
> hopefully will look like this:
>
> cceduc
> lhs=1
> hs=2
> some college=3
> college=4
>
> Any suggestions would be greatly appreciated! I can definitely provide more
> info if the above question doesn't make sense.
>
> Regards,
> Greg
> --
> View this message in context: http://www.nabble.com/creating-a-new-variable-from-a-series-of-variables-tp23361101p23361101.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@LISTSERV.UGA.EDU (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@LISTSERV.UGA.EDU (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: creating a new variable from a series of variables

Greg
In reply to this post by Art Kendall
Also, my original goal is to create an education variable from my original file which is a total file, and then merge it to a specific group file (i.e. blacks). The specific group file is an individual level data file.

Thanks,
Greg


Art Kendall wrote
What values do you have in your 4 original variables?
Open a new instance of SPSS.  Copy the syntax below to a syntax file.
Click <run>. Click <all>.
Is this what you are looking for?

data list list /id (f3)
  region  cceduclhs  cceduchs  cceducsomecoll  cceduccollege (5f1).
begin data
1 1 0 0 0 1
2 1 0 0 1 0
3 1 0 1 0 0
4 1 1 0 0 0
4 1 1 1 0 0
5 1 0 0 1 1
6 2 0 0 0 1
7 2 0 0 1 0
8 2 0 1 0 0
9 2 1 0 0 0
10 2 1 1 0 0
11 2 0 0 1 1
end data.
numeric cceduc (f1).
compute cceduc = 0.
value labels cceduc
 0 'not found'
 1 'lhs'
 2 'hs'
 3 'some college'
 4 'college'/.
* find highest level flagged'.
do repeat flag = cceduclhs  cceduchs  cceducsomecoll  cceduccollege/
  callit = 1 to 4.
if flag eq 1 cceduc = callit.
end repeat.
LIST .

Art Kendall
Social Research Consultants

grigoris wrote:
> Hi everyone,
>
> I have a dataset that looks like this:
>
> region  cceduclhs  cceduchs  cceducsomecoll  cceduccollege
>  1         8405  4239         5007                       4784
>  2          2888       1640            2312                 1638
>
> The above units except for the region variable are individuals. For example,
> for cceduclhs in region 1, we have 8,405 individuals with less than a high
> school diploma.
>
> I want to recode the above variables, except region, into an ordinal that
> hopefully will look like this:
>
> cceduc
> lhs=1
> hs=2
> some college=3
> college=4
>
> Any suggestions would be greatly appreciated! I can definitely provide more
> info if the above question doesn't make sense.
>
> Regards,
> Greg
> --
> View this message in context: http://www.nabble.com/creating-a-new-variable-from-a-series-of-variables-tp23361101p23361101.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@LISTSERV.UGA.EDU (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@LISTSERV.UGA.EDU (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: creating a new variable from a series of variables

Richard Ristow
In reply to this post by Greg
At 07:42 PM 5/3/2009, grigoris wrote:

I have a dataset that looks like this:
region  cceduclhs  cceduchs  cceducsomecoll  cceduccollege
 1        8405      4239         5007           4784
 2        2888      1640         2312           1638

The above units except for the region variable are individuals. For example,
for cceduclhs in region 1, we have 8,405 individuals with less than a high
school diploma.

I want to recode the above variables, except region, into an ordinal that
hopefully will look like this:

cceduc
lhs=1
hs=2
some college=3
college=4

I'm not sure what you want, but maybe this?

VARSTOCASES
 /MAKE Number
  FROM cceduclhs cceduchs cceducsomecoll cceduccollege
 /INDEX = cceduc(4)
 /KEEP  =  region
 /NULL  = KEEP.

 
Variables to Cases
|-----------------------------|---------------------------|
|Output Created               |04-MAY-2009 12:31:33       |
|-----------------------------|---------------------------|
 
Generated Variables
|------|------|
|Name  |Label |
|------|------|
|cceduc|<none>|
|Number|<none>|
|------|------|
 
Processing Statistics
|-------------|-|
|Variables In |5|
|Variables Out|3|
|-------------|-|

 
LIST.
|-----------------------------|---------------------------|
|Output Created               |04-MAY-2009 12:31:33       |
|-----------------------------|---------------------------|
region cceduc Number

    1      1   8405
    1      2   4239
    1      3   5007
    1      4   4784
    2      1   2888
    2      2   1640
    2      3   2312
    2      4   1638

Number of cases read:  8    Number of cases listed:  8

=============================
APPENDIX: Test data, and code
=============================
DATA LIST LIST/
   region  cceduclhs  cceduchs  cceducsomecoll  cceduccollege.
BEGIN DATA
    1        8405      4239         5007           4784
    2        2888      1640         2312           1638
END DATA.

FORMATS region TO cceduccollege (F4).

LIST.

VARSTOCASES 
 /MAKE Number
  FROM cceduclhs cceduchs cceducsomecoll cceduccollege
 /INDEX = cceduc(4)
 /KEEP  =  region
 /NULL  = KEEP.

LIST.

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