Re: Joint two colums in one

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

Re: Joint two colums in one

Art Kendall
Is this what you have? 3 variables,
id a b
1  1 101
2  2 102
3  3 103
4  4 104
5  0 105
6  0 106


and you want to go from a "wide" to "long" layout like this
with 2 variables id and c?
1 1
2 2
3 3
4 4
5 0
6 0
1 101
2 102
3 103
4 104
5 105
6 106

If this is what you want and it is just an excise and you do not need an audit trail
just select cut and paste in the data view
even in excel you could just select copy and paste why would you need a loop?

Art Kendall
Social Research Consultants

On 1/28/2012 1:38 PM, Johanna Muñoz wrote:
The thing is i have two variables a an b... a with id from 1 to na and b with id from 1 to nb, not big deal,,,if we traduce that in terms of excel would be,, i have a variable "A" that goes from A1:A100 and a variable "B" that goes from B1:B133 i only need to create a new variable "C" that is equal to copy paste "A" in column  "C" and then in the cells C100 copy and paste the other variable  "B" in order to get a variable  "C" that goes from C1:C233. In excel is easy to do that with a loop,, but in SPSS i dont have any idea..  
The variables are numbers,, the only thing is there are also missing values that i have to keep in the new  variable..
Thanks for your reply,, :)

Johanna

On Sat, Jan 28, 2012 at 6:50 AM, Art Kendall <[hidden email]> wrote:
please tell us more.
Are the variables numbers or strings?
Are the variables always the same width?  e.g., 1 digit for a variable that goes from 1 to 5.  2 digits for an age.

please give us a few examples of what the two variables could be and what you want as a result.


Art Kendall
Social Research Consultants

On 1/27/2012 11:32 PM, Johanna Muñoz wrote:
Hi I need to know how to joint two variables in one. In other words I
nned to joint two colums in only one. I don't know anything about
programming in spss. Thanks for ur help

===================== 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: Joint two colums in one

Art Kendall
Are you basically trying to change variables to cases as in the example I posted?  I.e., considering a and be to ranges (sets) of variable?
Are you trying to do something like this?
 a1 to a5 is a set of measures on cases with IDs. (e.g., age sex IQ height weight)as guessed by 1 person
For the same cases you have another set of the same measures
(age sex IQ height weight)as guessed by  another person.
Some guesses were made by only one person not both.

If you describe your data more explicitly members of the list may be able to suggest ways to achieve what you want.

of the several things I think you might mean, none would need any LOOP statements.


Art Kendall
Social Research Consultants

On 1/28/2012 4:42 PM, Johanna Muñoz wrote:
Hi because i have to move a lot of information in that way,, is not only one variable,, for that reason i would like to know how to do it with loops. :)

Thanks

Johanna


On Sat, Jan 28, 2012 at 2:11 PM, Art Kendall <[hidden email]> wrote:
Is this what you have? 3 variables,
id a b
1  1 101
2  2 102
3  3 103
4  4 104
5  0 105
6  0 106


and you want to go from a "wide" to "long" layout like this
with 2 variables id and c?
1 1
2 2
3 3
4 4
5 0
6 0
1 101
2 102
3 103
4 104
5 105
6 106

If this is what you want and it is just an excise and you do not need an audit trail
just select cut and paste in the data view
even in excel you could just select copy and paste why would you need a loop?


Art Kendall
Social Research Consultants

On 1/28/2012 1:38 PM, Johanna Muñoz wrote:
The thing is i have two variables a an b... a with id from 1 to na and b with id from 1 to nb, not big deal,,,if we traduce that in terms of excel would be,, i have a variable "A" that goes from A1:A100 and a variable "B" that goes from B1:B133 i only need to create a new variable "C" that is equal to copy paste "A" in column  "C" and then in the cells C100 copy and paste the other variable  "B" in order to get a variable  "C" that goes from C1:C233. In excel is easy to do that with a loop,, but in SPSS i dont have any idea..  
The variables are numbers,, the only thing is there are also missing values that i have to keep in the new  variable..
Thanks for your reply,, :)

Johanna

On Sat, Jan 28, 2012 at 6:50 AM, Art Kendall <[hidden email]> wrote:
please tell us more.
Are the variables numbers or strings?
Are the variables always the same width?  e.g., 1 digit for a variable that goes from 1 to 5.  2 digits for an age.

please give us a few examples of what the two variables could be and what you want as a result.


Art Kendall
Social Research Consultants

On 1/27/2012 11:32 PM, Johanna Muñoz wrote:
Hi I need to know how to joint two variables in one. In other words I
nned to joint two colums in only one. I don't know anything about
programming in spss. Thanks for ur help


===================== 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: Joint two colums in one

David Marso
Administrator
In reply to this post by Art Kendall
data list free / id a b.
begin data
1 2 3
2 3 4
3 4 5
end data,
XSAVE OUTFILE 'tempcopy.sav'.
exe.
add files / file * / FILE 'tempcopy.sav' / IN=flag.
COMPUTE C=A.
IF FLAG C=B.
list.


Art Kendall wrote
Is this what you have? 3 variables,
      id a b
      1  1 101
      2  2 102
      3  3 103
      4  4 104
      5  0 105
      6  0 106
   
    and you want to go from a "wide" to "long" layout like this
    with 2 variables id and c?
    1 1
    2 2
    3 3
    4 4
    5 0
    6 0
    1 101
    2 102
    3 103
    4 104
    5 105
    6 106
   
    If this is what you want and it is just an excise and you do not
    need an audit trail
    just select cut and paste in the data view
    even in excel you could just select copy and paste why would you
    need a loop?
   
    Art Kendall
Social Research Consultants
   
    On 1/28/2012 1:38 PM, Johanna Muñoz wrote:
    The thing is i have two variables a an b... a with id
      from 1 to na and b with id from 1 to nb, not big deal,,,if we
      traduce that in terms of excel would be,, i have a variable "A"
      that goes from A1:A100 and a variable "B" that goes from B1:B133 i
      only need to create a new variable "C" that is equal to copy paste
      "A" in column  "C" and then in the cells C100 copy and paste the
      other variable  "B" in order to get a variable  "C" that goes from
      C1:C233. In excel is easy to do that with a loop,, but in SPSS i
      dont have any idea..  
     
        The variables are numbers,, the only thing is there are also
        missing values that i have to keep in the new  variable..
      Thanks for your reply,, :)
     
     
      Johanna
       
       
          On Sat, Jan 28, 2012 at 6:50 AM, Art Kendall < [hidden email] >
          wrote:
         
            please tell us more.
            Are the variables numbers or strings?
            Are the variables always the same width?  e.g., 1 digit for
            a variable that goes from 1 to 5.  2 digits for an age.
           
            please give us a few examples of what the two variables
            could be and what you want as a result.
           
           
            Art Kendall
            Social Research Consultants
           
            On 1/27/2012 11:32 PM, Johanna Muñoz wrote:
           
              Hi I need to know how to joint two variables in one. In
              other words I
              nned to joint two colums in only one. I don't know
              anything about
              programming in spss. Thanks for ur help
           
         
       
       
     
   
 


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