Hello Listserv Participants,
I have time series data in columns, see below
and wanted to turn it into rows, see below, dropping all the missing value records
I
think of splitting the data into 40 datasets and merge them using Add Cases command but I’d like to learn more syntax. Any help? Thank in advance.
Boreak This email is intended solely for the named addressee. |
Lookup VARSTOCASES
Solution would look something like this: VARSTOCASES /MAKE Data FROM Var1 to Var40 /NULL=DROP /INDEX=VarName(Data). |
In reply to this post by Boreak Silk
By the way, the format of your original data is typically refereed to as WIDE format (or even sometimes as FAT format) and when restructured as you desire, is known as LONG format. In most cases LONG format is a much preferred format to store and work with the data.
|
Administrator
|
In reply to this post by Boreak Silk
As Jignesh posted, this is a straightforward application of VARSTOCASES.
Why you would ever split the data into 40 datasets is incomprehensible. Before VARSTOCASES we would do something like. VECTOR vars=var1 TO var40. LOOP varnum=1 TO 40. COMPUTE variable=vars(I). XSAVE OUTFILE <filespec> / KEEP ID varnum variable. END LOOP. EXECUTE. GET FILE <filespec>. This sort of code is rarely required anymore except in cases where one might want only certain rows generated conditionally based upon some computation or logical evaluation done within the loop. Example. setup as before... VECTOR... LOOP... DO IF vars(I) LE vars(I+I) AND SUM(vars(I-1),vars(I+1)) GT 10). COMPUTE vi=vars(I) . COMPUTE varsii1=vars(I+I)-vars(I). COMPUTE vargap=SUM(vars(I-1),vars(I+1)) . XSAVE ... /KEEP ...vi varsii1 vagap ... END IF. END LOOP. .......... Something which can't be done within the VARSTOCASES and might be a RPITA to do afterwards.
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?" |
In reply to this post by Boreak Silk
Did you look at VARSTOCASES? Melissa From: SPSSX(r) Discussion [mailto:[hidden email]]
On Behalf Of Boreak Silk Hello Listserv Participants,
I have time series data in columns, see below
and wanted to turn it into rows, see below, dropping all the missing value records
I
think of splitting the data into 40 datasets and merge them using Add Cases command but I’d like to learn more syntax. Any help?
Thank in advance.
Boreak This email is intended solely for the named addressee. ===================== 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
This correspondence contains proprietary information some or all of which may be legally privileged; it is for the intended recipient only. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this correspondence and completely dispose of the correspondence immediately. Please notify the sender if you have received this email in error. NOTE: Messages to or from the State of Connecticut domain may be subject to the Freedom of Information statutes and regulations. ===================== 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 |