How can I replicate a value of a particular row of a column for all rows of these columns?
e.g Original variable variable1 1234 0000 0000 0000 0000 0000 0000 New variable 1234 1234 1234 1234 1234 1234 1234 I´d like do it give the index of the line. How I do that? Thanks |
How can I replicate a value of a particular row of a column for all rows of these columns?
e.g
Original variable variable1 1234
0000 0000
0000 0000
0000 0000
New variable
1234 1234
1234 1234
1234 1234
1234 I´d like do it give the index of the line. How I do that? Thanks Sérgio Henrique Almeida da Silva Junior
Doutorando em Epidemiologia em Saúde Pública Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ http://lattes.cnpq.br/1611345552843383 Tel: (21) 968463637 |
Administrator
|
In reply to this post by shasj
In the example you show, the "value of a particular row" is the value in the first row. Is that always the case? If so, look up AGGREGATE and pay attention to the FIRST function. If it is not always the value in the first row, please clarify how the "particular row" is selected.
HTH.
--
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/). |
The value always appears in the first row but may have different values at different datasets. thanks 2014/1/7 Bruce Weaver [via SPSSX Discussion] <[hidden email]> In the example you show, the "value of a particular row" is the value in the first row. Is that always the case? If so, look up AGGREGATE and pay attention to the FIRST function. If it is not always the value in the first row, please clarify how the "particular row" is selected. Sérgio Henrique Almeida da Silva Junior
Doutorando em Epidemiologia em Saúde Pública Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ http://lattes.cnpq.br/1611345552843383 Tel: (21) 968463637 |
In reply to this post by Bruce Weaver
Thanks I do this AGGREGATE /OUTFILE=* MODE=ADDVARIABLES OVERWRITEVARS=YES /BREAK= /var1_first=FIRST(var1).
2014/1/7 Sérgio Henrique almeida da silva ju <[hidden email]>
Sérgio Henrique Almeida da Silva Junior
Doutorando em Epidemiologia em Saúde Pública Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ http://lattes.cnpq.br/1611345552843383 Tel: (21) 968463637 |
In reply to this post by shasj
data list list /variable1.
begin data 1234 0 0 0 0 0 end data. do if $casenum=1. compute newvariable=variable1. else. compute newvariable=lag(newvariable). end if. list. Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] From: shasj <[hidden email]> To: [hidden email], Date: 01/07/2014 10:42 AM Subject: Re: Replicate value line in SPSS Sent by: "SPSSX(r) Discussion" <[hidden email]> The value always appears in the first row but may have different values at different datasets. thanks 2014/1/7 Bruce Weaver [via SPSSX Discussion] <[hidden email]> In the example you show, the "value of a particular row" is the value in the first row.  Is that always the case?  If so, look up AGGREGATE and pay attention to the FIRST function.  If it is not always the value in the first row, please clarify how the "particular row" is selected. HTH. shasj wrote How can I replicate a value of a particular row of a column for all rows of these columns? e.g Original variable variable1 1234 0000 0000 0000 0000 0000 0000 New variable 1234 1234 1234 1234 1234 1234 1234 I´d like do it give the index of the line. How I do that? Thanks -- If you reply to this email, your message will be added to the discussion below: http://spssx-discussion.1045642.n5.nabble.com/Replicate-value-line-in-SPSS-tp5723814p5723816.html To unsubscribe from Replicate value line in SPSS, click here. NAML -- Sérgio Henrique Almeida da Silva Junior Doutorando em Epidemiologia em Saúde Pública Escola Nacional de Saúde Pública Sérgio Arouca - ENSP/FIOCRUZ http://lattes.cnpq.br/1611345552843383 Tel: (21) 968463637 http://www.linkedin.com/profile/view?id=250437145&trk=tab_pro View this message in context: Re: Replicate value line in SPSS Sent from the SPSSX Discussion mailing list archive at Nabble.com. |
Administrator
|
This post was updated on .
In reply to this post by shasj
Not terribly obvious what you want, but consider the LAG function.
IF (variable1=0000) variable1=LAG(variable1). use quotes if it is a string! IF (variable1="0000") variable1=LAG(variable1). If there are a bunch of them. DO REPEAT v=<varlist insert your variables>. IF (v=0000) v=LAG(v). END REPEAT. etc...
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?" |
AGGREGATE also works:
AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /newvariable=FIRST(variable1). Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] From: David Marso <[hidden email]> To: [hidden email], Date: 01/07/2014 11:10 AM Subject: Re: Replicate value line in SPSS Sent by: "SPSSX(r) Discussion" <[hidden email]> No terribly obvious what you want, but consider the LAG function. IF (variable1=0000) variable1=LAG(variable1). use quotes if it is a string! IF (variable1="0000") variable1=LAG(variable1). If there are a bunch of them. DO REPEAT v=<varlist insert your variables>. IF (v=0000) v=LAG(v). END REPEAT. etc... shasj wrote > How can I replicate a value of a particular row of a column for all rows > of these columns? > > e.g > > Original variable > > variable1 > 1234 > 0000 > 0000 > 0000 > 0000 > 0000 > 0000 > > New variable > 1234 > 1234 > 1234 > 1234 > 1234 > 1234 > 1234 > > I´d like do it give the index of the line. > > How I do that? > > Thanks ----- 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/Replicate-value-line-in-SPSS-tp5723814p5723823.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 |
Administrator
|
Sure. Aggregate works as well, but consumes a data pass. Conversely one can stack up a huge number of transformations without running through the data.
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?" |
Free forum by Nabble | Edit this page |