|
HI to all,
I have one question about recoding I guess. I have this kind of data data list list /v1 to v3 . begin data . 1 2 . . . 3 4 . 4 1 . 3 end data . And I would like to turn it into this v1 v2 v3 1 2 3 4 4 1 3 Is there some simple and clever way of doing this? I think I read some solution to this problem in this list but I could not locate that specific message:) Regards Samir Samir Omerovic Researcher ___________________________ GfK BH d.o.o. Skenderija 44 71 000 Sarajevo Bosnia and Herzegovina Phone +387 33 550 300 Fax +387 33 444 226 [hidden email] www.gfk.ba Before printing this e-mail, please consider environment protection. This e-mail (and any attachment/s) contains confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. Ova e-poruka sadrži povjerljive i/ili povlaštene podatke. Ako niste osoba naznačena kao primalac molimo odmah upozoriti pošiljaoca i uništiti primljenu e-poruku. Neautorizirano kopiranje, objavljivanje ili distribucija sadržaja iz elektronske poruke striktno je zabranjeno. ====================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 |
|
Hi Samir,
Not extremely simple & clever, but it works: vector v = v1 to v3. loop #now = 2 to 3. - do if not missing(v(#now)) . - loop #i = 1 to #now - 1 /* now look whether we have a free place*/. - compute #slot = #i. - end loop if missing(v(#i)). - do if missing(v(#slot)) /*if yes, move the data*/. - compute v(#slot) = v(#now). - compute v(#now) = $sysmis. - end if. - end if. end loop. exe. HTH Jan -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Samir Omerovic Sent: Wednesday, January 23, 2008 9:52 AM To: [hidden email] Subject: Restructuring data HI to all, I have one question about recoding I guess. I have this kind of data data list list /v1 to v3 . begin data . 1 2 . . . 3 4 . 4 1 . 3 end data . And I would like to turn it into this v1 v2 v3 1 2 3 4 4 1 3 Is there some simple and clever way of doing this? I think I read some solution to this problem in this list but I could not locate that specific message:) Regards Samir Samir Omerovic Researcher ___________________________ GfK BH d.o.o. Skenderija 44 71 000 Sarajevo Bosnia and Herzegovina Phone +387 33 550 300 Fax +387 33 444 226 [hidden email] www.gfk.ba Before printing this e-mail, please consider environment protection. This e-mail (and any attachment/s) contains confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. Ova e-poruka sadrži povjerljive i/ili povlaštene podatke. Ako niste osoba naznačena kao primalac molimo odmah upozoriti pošiljaoca i uništiti primljenu e-poruku. Neautorizirano kopiranje, objavljivanje ili distribucija sadržaja iz elektronske poruke striktno je zabranjeno. ======= 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 _____ Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem. This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission. -.- -- ===================== 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 |
|
Hi Jan,
Thanks for being so quick with the solution. I must admit I thought I would be able to figure it out from your syntax but I have never worked with vector nor loop so I have one more question. If I have more than 3 variables (v1 to v9 or even higher) how to adjust the syntax? Thanks once more Samir -----Original Message----- From: Spousta Jan [mailto:[hidden email]] Sent: Wednesday, January 23, 2008 10:22 AM To: Samir Omerovic; [hidden email] Subject: RE: Restructuring data Hi Samir, Not extremely simple & clever, but it works: vector v = v1 to v3. loop #now = 2 to 3. - do if not missing(v(#now)) . - loop #i = 1 to #now - 1 /* now look whether we have a free place*/. - compute #slot = #i. - end loop if missing(v(#i)). - do if missing(v(#slot)) /*if yes, move the data*/. - compute v(#slot) = v(#now). - compute v(#now) = $sysmis. - end if. - end if. end loop. exe. HTH Jan -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Samir Omerovic Sent: Wednesday, January 23, 2008 9:52 AM To: [hidden email] Subject: Restructuring data HI to all, I have one question about recoding I guess. I have this kind of data data list list /v1 to v3 . begin data . 1 2 . . . 3 4 . 4 1 . 3 end data . And I would like to turn it into this v1 v2 v3 1 2 3 4 4 1 3 Is there some simple and clever way of doing this? I think I read some solution to this problem in this list but I could not locate that specific message:) Regards Samir Samir Omerovic Researcher ___________________________ GfK BH d.o.o. Skenderija 44 71 000 Sarajevo Bosnia and Herzegovina Phone +387 33 550 300 Fax +387 33 444 226 [hidden email] www.gfk.ba Before printing this e-mail, please consider environment protection. This e-mail (and any attachment/s) contains confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. Ova e-poruka sadrži povjerljive i/ili povlaštene podatke. Ako niste osoba naznačena kao primalac molimo odmah upozoriti pošiljaoca i uništiti primljenu e-poruku. Neautorizirano kopiranje, objavljivanje ili distribucija sadržaja iz elektronske poruke striktno je zabranjeno. ======= 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 _____ Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem. This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission. -.- -- -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.516 / Virus Database: 269.19.7/1234 - Release Date: 20.1.2008 14:15 ===================== 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 |
| Free forum by Nabble | Edit this page |
