|
I've got some data like this:
Country DATE_ GDP China JAN 2010 1000 China FEB 2010 1110 China MAR 2010 1200 China APR 2010 1250 Brazil JAN 2010 500 Brazil FEB 2010 550 Brazil MAR 2010 620 Brazil APR 2010 660 How can I convert this to something like this, where I'm taking data from "neighboring" rows: Country DATE_ Current_GDP Prev_Month Next_Month China JAN 2010 1000 . 1110 China FEB 2010 1110 1000 1200 China MAR 2010 1200 1110 1250 China APR 2010 1250 1200 . Brazil JAN 2010 500 . 550 Brazil FEB 2010 550 500 620 Brazil MAR 2010 620 550 660 Brazil APR 2010 660 620 . Mark Lavender Application Architect and Developer Finance IT [hidden email] ===================== 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 |
|
Sorry....I looked for the answer for an hour or two before posting and then
5 minutes later I read about SHIFT VALUE. So nevermind. Mark Lavender Application Architect and Developer Finance IT [hidden email] From: Mark Lavender/Raleigh/IBM To: [hidden email] Date: 10/06/2010 01:30 PM Subject: Copy values from one case to another I've got some data like this: Country DATE_ GDP China JAN 2010 1000 China FEB 2010 1110 China MAR 2010 1200 China APR 2010 1250 Brazil JAN 2010 500 Brazil FEB 2010 550 Brazil MAR 2010 620 Brazil APR 2010 660 How can I convert this to something like this, where I'm taking data from "neighboring" rows: Country DATE_ Current_GDP Prev_Month Next_Month China JAN 2010 1000 . 1110 China FEB 2010 1110 1000 1200 China MAR 2010 1200 1110 1250 China APR 2010 1250 1200 . Brazil JAN 2010 500 . 550 Brazil FEB 2010 550 500 620 Brazil MAR 2010 620 550 660 Brazil APR 2010 660 620 . Mark Lavender Application Architect and Developer Finance IT [hidden email] ===================== 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
|
In reply to this post by Mark Lavender-3
If your SPSS version is recent enough, look up the SHIFT VALUES command. Here's an example from the Help files. DATA LIST FREE /Var1 (F1). BEGIN DATA 0 1 9 0 1 END DATA. VARIABLE LABEL Var1 'Original Variable'. VALUE LABELS Var1 0 'No' 1 'Yes' 9 'Missing'. MISSING VALUES Var1(9). SHIFT VALUES VARIABLE=Var1 RESULT=Var1_Lead LEAD=1 /VARIABLE=Var1 RESULT=Var1_Lag LAG=1 /VARIABLE=Var1 RESULT=Var1_Shift SHIFT=-1. The resulting data file looks like this: Var1 Var1_Lead Var1_Lag Var1_Shift 0 1 . . 1 9 0 0 9 0 1 1 0 1 9 9 1 . 0 0 Number of cases read: 5 Number of cases listed: 5
--
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/). |
| Free forum by Nabble | Edit this page |
