|
Say I have a data set of 1000 variables, v1 to v1000. I create a new variable v455rec that is a recoded variable of v455. Now I want to position v455rec next to v455. I understand I can do it with the mouse which is quite cumbersome and annoying, especially if I have several of such operations. I can also do it per syntax with MATCH FILES FILE = * /KEEP v1 TO v455 v455rec ALL. This, however, I find a bit verbose when much recoding is going on. I'd like to propose an optional subcommand for commands like COMPUTE or IF like e.g. COMPUTE v455rec = (v455 <= 3) * 1 + (v455 > 3) * 2 /POSITION = AFTER (v455). What do you think of this? Mario Giesel Munich, Germany |
|
Mario If yours vars are all v1 to vn, try: sort variables by name. John F Hall MA (Cantab) Dip Ed (Dunelm) [Retired academic survey researcher] Email: [hidden email] Website: Journeys in Survey Research Course: Survey Analysis Workshop (SPSS) From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Mario Giesel Say I have a data set of 1000 variables, v1 to v1000. I create a new variable v455rec that is a recoded variable of v455. Now I want to position v455rec next to v455. I understand I can do it with the mouse which is quite cumbersome and annoying, especially if I have several of such operations. I can also do it per syntax with MATCH FILES FILE = * /KEEP v1 TO v455 v455rec ALL. This, however, I find a bit verbose when much recoding is going on. I'd like to propose an optional subcommand for commands like COMPUTE or IF like e.g. COMPUTE v455rec = (v455 <= 3) * 1 + (v455 > 3) * 2 /POSITION = AFTER (v455). What do you think of this? Mario Giesel Munich, Germany ===================== 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 |
|
Thanks, Jon. Normally, this does not work as similar named variables are mixed by this method. Names v1, v2 ... were chosen only for simplicity. Mario Giesel Munich, Germany John F Hall <[hidden email]> schrieb am 11:22 Mittwoch, 16.Mai 2018: Mario If yours vars are all v1 to vn, try: sort variables by name. John F Hall MA (Cantab) Dip Ed (Dunelm) [Retired academic survey researcher] Email: [hidden email] Website: Journeys in Survey Research Course: Survey Analysis Workshop (SPSS) From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Mario Giesel Sent: 16 May 2018 09:29 To: [hidden email] Subject: Positioning a new variable Say I have a data set of 1000 variables, v1 to v1000. I create a new variable v455rec that is a recoded variable of v455. Now I want to position v455rec next to v455. I understand I can do it with the mouse which is quite cumbersome and annoying, especially if I have several of such operations. I can also do it per syntax with MATCH FILES FILE = * /KEEP v1 TO v455 v455rec ALL. This, however, I find a bit verbose when much recoding is going on. I'd like to propose an optional subcommand for commands like COMPUTE or IF like e.g. COMPUTE v455rec = (v455 <= 3) * 1 + (v455 > 3) * 2 /POSITION = AFTER (v455). What do you think of this? Mario Giesel Munich, Germany ===================== 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 |
|
So you're stuck with: save out <'filepath'> /keep <varlist> which is quicker. John F Hall MA (Cantab) Dip Ed (Dunelm) [Retired academic survey researcher] Email: [hidden email] Website: Journeys in Survey Research Course: Survey Analysis Workshop (SPSS) From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Mario Giesel Thanks, Jon. Normally, this does not work as similar named variables are mixed by this method. Names v1, v2 ... were chosen only for simplicity. Mario Giesel Munich, Germany John F Hall <[hidden email]> schrieb am 11:22 Mittwoch, 16.Mai 2018: Mario If yours vars are all v1 to vn, try: sort variables by name. John F Hall MA (Cantab) Dip Ed (Dunelm) [Retired academic survey researcher] Email: [hidden email] Website: Journeys in Survey Research Course: Survey Analysis Workshop (SPSS) From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Mario Giesel Say I have a data set of 1000 variables, v1 to v1000. I create a new variable v455rec that is a recoded variable of v455. Now I want to position v455rec next to v455. I understand I can do it with the mouse which is quite cumbersome and annoying, especially if I have several of such operations. I can also do it per syntax with MATCH FILES FILE = * /KEEP v1 TO v455 v455rec ALL. This, however, I find a bit verbose when much recoding is going on. I'd like to propose an optional subcommand for commands like COMPUTE or IF like e.g. COMPUTE v455rec = (v455 <= 3) * 1 + (v455 > 3) * 2 /POSITION = AFTER (v455). What do you think of this? Mario Giesel Munich, Germany ===================== 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 ===================== 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 |
|
In reply to this post by spss.giesel@yahoo.de
try something like this untested approach
dataset copy newname. match files /file= newname. /keep myvar1 to myvar455, myRvar455,all. *might need execute. ----- Art Kendall Social Research Consultants -- Sent from: http://spssx-discussion.1045642.n5.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
Art Kendall
Social Research Consultants |
|
In reply to this post by spss.giesel@yahoo.de
You could create an extension command or a macro that would let you reorder one or more variables as above by generating the MATCH FILES command, but adding a subcommand to COMPUTE and similar commands would introduce syntactic ambiguity - is / a divide symbol or a subcommand start? The example above is almost a valid compute statement, so reporting real syntax errors would become a lot more difficult. Execution order might also be an issue, since TO could occur in a function in the same COMPUTE. On Wed, May 16, 2018 at 1:28 AM, Mario Giesel <[hidden email]> wrote:
|
|
Administrator
|
My first thought was to stuff MATCH FILES in a macro. But in the end, it
doesn't really save that many keystrokes. For the example below, it's the difference between these two lines: !OrderVars vlist = v1 to v3 v3rec ALL. MATCH FILES FILE = * /KEEP v1 to v3 v3rec ALL. * --------- Example --------------. DEFINE !OrderVars (vlist = !CMDEND) MATCH FILES FILE = * /KEEP !vlist. EXECUTE. !ENDDEFINE. * Read in some data. NEW FILE. DATASET CLOSE ALL. DATA LIST LIST / v1 to v5 (5F1). BEGIN DATA 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 END DATA. COMPUTE v3rec = 10-v3. FORMATS v3rec (F1). !OrderVars vlist = v1 to v3 v3rec ALL. LIST. Output: v1 v2 v3 v3rec v4 v5 1 2 3 7 4 5 6 7 8 2 9 1 2 3 4 6 5 6 7 8 9 1 1 2 3 4 5 5 6 7 Number of cases read: 5 Number of cases listed: 5 Jon Peck wrote > You could create an extension command or a macro that would let you > reorder > one or more variables as above by generating the MATCH FILES command, but > adding a subcommand to COMPUTE and similar commands would introduce > syntactic ambiguity - is / a divide symbol or a subcommand start? The > example above is almost a valid compute statement, so reporting real > syntax > errors would become a lot more difficult. Execution order might also be > an > issue, since TO could occur in a function in the same COMPUTE. > > On Wed, May 16, 2018 at 1:28 AM, Mario Giesel < > 0000055bfbeaad14-dmarc-request@.uga >> wrote: > >> Say I have a data set of 1000 variables, v1 to v1000. >> I create a new variable v455rec that is a recoded variable of v455. >> Now I want to position v455rec next to v455. >> I understand I can do it with the mouse which is quite cumbersome and >> annoying, especially if I have several of such operations. >> I can also do it per syntax with MATCH FILES FILE = * /KEEP v1 TO v455 >> v455rec ALL. >> This, however, I find a bit verbose when much recoding is going on. >> >> I'd like to propose an optional subcommand for commands like COMPUTE or >> IF >> like e.g. >> COMPUTE v455rec = (v455 <= 3) * 1 + (v455 > 3) * 2 /POSITION = AFTER >> (v455). >> >> What do you think of this? >> >> Mario Giesel >> Munich, Germany >> ===================== 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 > > > > > -- > Jon K Peck > jkpeck@ > > ===================== > 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 ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- Sent from: http://spssx-discussion.1045642.n5.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
--
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/). |
|
Administrator
|
This post was updated on .
In reply to this post by spss.giesel@yahoo.de
As Jon stated, adding a sbcommand to COMPUTE or IF would create a syntactic
ambiguity. Why not 'subclass' COMPUTE as follows? DEFINE !Firstvar () X !ENDDEFINE. DEFINE !COMPUTE (!POS !CHAREND(":") /!POS !CHAREND("=") /!POS !CMDEND) COMPUTE !2=!3. MATCH FILES / FILE * / KEEP !Firstvar TO !1 !2 ALL. !ENDDEFINE. NEW FILE. DATASET CLOSE ALL. OUTPUT CLOSE ALL. DATA LIST FREE /X a b c. BEGIN DATA 1 2 3 4 END DATA. SET MPRINT ON. !COMPUTE b : bnew=EXP(b). !COMPUTE c : cnew=LN(c). !COMPUTE a : anew= a/2. LIST. X a anew b bnew c cnew 1.00 2.00 1.00 3.00 20.09 4.00 1.39 ----- 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?" -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (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?" |
|
I am not sure about the extra overhead of stacked MATCH FILE commands, but I suspect that this reordering would often involve multiple variables. So it would make sense to have a syntactically parsimonious way to move variables around that would handle more than one at a time. It might have syntax like STATS REORDER x > y w > z a < b ... where > means left variable after right variable and < means left variable before right variable. I don't think even David could create a macro to do this, but a Python extension command for this would be pretty simple. On Wed, May 16, 2018 at 3:50 PM David Marso <[hidden email]> wrote: As Jon stated, adding a sbcommand to COMPUTE or IF would create a syntactic -- |
|
Perhaps a more generalized approach could be based on prefixes.
for example, prefix recoded variables by r_ given raw variables Age Height Likert1 to Likert20 recode variables to coarsen age and height to e.g., r_Age r_Height recode some Likert items to reflect them r_Likert3 r_Likert6 r_Likert9 r_Likert17 then there could be Pythons to (1) place the recoded variables after the specific raw variables Age r_Age Height r_Height etc. OR (2) place the recoded variables before before the specific raw variables r_Age Age r_Height Height OR what would be useful for Likert items where some are reflected (3) Place the items that will be parts of a summative scale together so a TO cam be used in a COMPUTE the raw items could be retained after those that will be used in the COMPUTE Likert1 Likert2 r_Likert3 Likert4 Likert5 r_Likert6 ... Likert20 Likert3 Likert6 Likert9 Likert17 Some arguments for the Pythons could be cut-and-pasted from the syntax to do the recodes. ----- Art Kendall Social Research Consultants -- Sent from: http://spssx-discussion.1045642.n5.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
Art Kendall
Social Research Consultants |
|
Administrator
|
In reply to this post by Jon Peck
NOPE! MATCH is a transformation. Should not be an issue.
This ran instantaneously. DEFINE !Firstvar () X !ENDDEFINE. DEFINE !COMPUTE (!POS !CHAREND(":") /!POS !CHAREND("=") /!POS !CMDEND) COMPUTE !2=!3. MATCH FILES / FILE * / KEEP !Firstvar TO !1 !2 ALL. !ENDDEFINE. NEW FILE. DATASET CLOSE ALL. OUTPUT CLOSE ALL. MATRIX. SAVE (TRUNC(UNIFORM(1000000,4)*5) +1)/OUTFILE * /VARIABLES=x a b c. END MATRIX. SET MPRINT ON. !COMPUTE b : bnew=EXP(b). !COMPUTE c : cnew=LN(c). !COMPUTE a : anew= a/2. EXECUTE. ----- 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?" -- Sent from: http://spssx-discussion.1045642.n5.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
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?" |
|
Administrator
|
Very nice.
https://i.imgflip.com/mkovb.jpg David Marso wrote > NOPE! MATCH is a transformation. Should not be an issue. > This ran instantaneously. > > > DEFINE !Firstvar () X !ENDDEFINE. > > DEFINE !COMPUTE (!POS !CHAREND(":") /!POS !CHAREND("=") /!POS !CMDEND) > COMPUTE !2=!3. > MATCH FILES / FILE * / KEEP !Firstvar TO !1 !2 ALL. > !ENDDEFINE. > > NEW FILE. > DATASET CLOSE ALL. > OUTPUT CLOSE ALL. > MATRIX. > SAVE (TRUNC(UNIFORM(1000000,4)*5) +1)/OUTFILE * /VARIABLES=x a b c. > END MATRIX. > > SET MPRINT ON. > > !COMPUTE b : bnew=EXP(b). > !COMPUTE c : cnew=LN(c). > !COMPUTE a : anew= a/2. > EXECUTE. > > > > > ----- > 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?" > -- > Sent from: http://spssx-discussion.1045642.n5.nabble.com/ > > ===================== > 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 ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- Sent from: http://spssx-discussion.1045642.n5.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
--
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 |
