Hello to everybody: I have data like this: DATA LIST LIST /id (A3) it01 (F1.0) it02 (F1.0) it03 (F1.0) it04 (F1.0). BEGIN DATA 001 0 0 0 0 002 0 0 1 0 003 0 1 1 0 004 0 1 0 1 005 1 0 0 0 006 1 0 1 0 007 1 1 1 0 008 1 1 1 1 009 0 1 1 1 010 1 1 0 0 END DATA. But for thousands of cases and 40-50 items in different data bases. What I need to do is to order and rename the items. I mean, item 01 should be the easiest and item 04 the hardest. For this example the mean (classical test theory difficulty) of each items are it01 = .50, it02 = .60, it03 =.60 and it04 =.30 So I need to do this: RENAME VARIABLES (it01 = it03) (it02 = it01) (it03 = it02) (it04 = it04). Of course I could do this by hand, (with some Excel help and couple of copy and paste), but I need to do this with many data bases, but I don’t know how to do it with syntax Thank you very much for your help Andres |
Administrator
|
By both reordering AND renaming don't you lose track of what the original variable name is?
Well that said, let the ensuing chaos be yours alone. Here goes nothing... I'm sure some pythonista will post some incomprehensible undocumented 2 or 3 liner, but I don't really give a RA. OLD SKOOL: -- DATA LIST LIST /id (A3) it01 (F1.0) it02 (F1.0) it03 (F1.0) it04 (F1.0). BEGIN DATA 001 0 0 0 0 002 0 0 1 0 003 0 1 1 0 004 0 1 0 1 005 1 0 0 0 006 1 0 1 0 007 1 1 1 0 008 1 1 1 1 009 0 1 1 1 010 1 1 0 0 END DATA. DATASET NAME rawdata. DATASET DECLARE agg. AGGREGATE OUTFILE agg/ BREAK / it01 TO it04=MEAN(it01 TO it04). DATASET ACTIVATE agg. FLIP. SORT CASES BY var001 (D). FLIP. DATASET NAME reordered. ADD FILES FILE reordered / FILE=rawdata /KEEP ID ALL. COMPUTE @=1. RENAME VARIABLES(CASE_LBL TO @ = it00 TO it05). SELECT IF (it00 NE 'var001'). EXECUTE. DELETE VARIABLES it00 it05.
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?" |
Dear David:
Thank you very much, this works fine. I don't need the original variables names, because this are databases simulated to fit a Rasch dichotomous model. I only want to have the item names ordered in correspondence to the proportion of correct answers Kind regards Andrés -----Mensaje original----- De: SPSSX(r) Discussion [mailto:[hidden email]] En nombre de David Marso Enviado el: lunes, 11 de mayo de 2015 07:14 p.m. Para: [hidden email] Asunto: Re: Help with sintax to sort variables by mean values By both reordering AND renaming don't you lose track of what the original variable name is? Well that said, let the ensuing chaos be yours alone. Here goes nothing... I'm sure some pythonista will post some incomprehensible undocumented 2 or 3 liner, but I don't really give a RA. OLD SKOOL: -- DATA LIST LIST /id (A3) it01 (F1.0) it02 (F1.0) it03 (F1.0) it04 (F1.0). BEGIN DATA 001 0 0 0 0 002 0 0 1 0 003 0 1 1 0 004 0 1 0 1 005 1 0 0 0 006 1 0 1 0 007 1 1 1 0 008 1 1 1 1 009 0 1 1 1 010 1 1 0 0 END DATA. DATASET NAME rawdata. DATASET DECLARE agg. AGGREGATE OUTFILE agg/ BREAK / it01 TO it04=MEAN(it01 TO it04). DATASET ACTIVATE agg. FLIP. SORT CASES BY var001 (D). FLIP. DATASET NAME reordered. ADD FILES FILE reordered / FILE=rawdata /KEEP ID ALL. COMPUTE @=1. RENAME VARIABLES(CASE_LBL TO @ = it00 TO it05). SELECT IF (it00 NE 'var001'). EXECUTE. DELETE VARIABLES it00 it05. ANDRES ALBERTO BURGA LEON wrote > Hello to everybody: > > I have data like this: > > DATA LIST LIST > /id (A3) it01 (F1.0) it02 (F1.0) it03 (F1.0) it04 (F1.0). > BEGIN DATA > 001 0 0 0 0 > 002 0 0 1 0 > 003 0 1 1 0 > 004 0 1 0 1 > 005 1 0 0 0 > 006 1 0 1 0 > 007 1 1 1 0 > 008 1 1 1 1 > 009 0 1 1 1 > 010 1 1 0 0 > END DATA. > But for thousands of cases and 40-50 items in different data bases. > > What I need to do is to order and rename the items. I mean, item 01 > should be the easiest and item 04 the hardest. > > For this example the mean (classical test theory difficulty) of each > items are it01 = .50, it02 = .60, it03 =.60 and it04 =.30 > > So I need to do this: RENAME VARIABLES (it01 = it03) (it02 = it01) > (it03 = > it02) (it04 = it04). > > > Of course I could do this by hand, (with some Excel help and couple > of copy and paste), but I need to do this with many data bases, but I > don't know how to do it with syntax > > > Thank you very much for your help > > Andres > > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Help-with-sintax-to-sort-variables-by-mean-values-tp5729546p5729547.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 ===================== 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 |