|
Hello,
I have installed R 2.7 and the R-plugin for SPSS 17.0.
Next I want to try things out.
So I start SPSS 17.0 and type in a new syntax file
BEGIN PROGRAM R.
print("Hello, world")
END PROGRAM.
Then I select these three lines and run them with the run button.
(The R program is not running).
Now at the bottom of my SPSS files it is indicated 'Running BEGIN PROGRAM' and nothing happens....
Can anyone help me any further? Why is this very very simple program not come to its end??
Do I have to install other things? Do I have to load first the SPSS library in R?
Thanks in advance, Karin
|
|
When you get
stuck at the "Running BEGIN PROGRAM" status, it usually means that
the backend has not received the entire program. It will not execute the
program until it sees END PROGRAM. Make sure that
the END PROGRAM line has actually been submitted, and be sure that it starts in
the first column and has no extra blanks as it needs to be matched exactly. HTH, Jon Peck From: SPSSX(r)
Discussion [mailto:[hidden email]] On
Behalf Of Karin Hello, I have installed R 2.7 and the R-plugin for SPSS 17.0. Next I want to try things out. So I start SPSS 17.0 and type in a new syntax file BEGIN PROGRAM R. print("Hello, world") END PROGRAM. Then I select these three lines and run them with the run button. (The R program is not running). Now at the bottom of my SPSS files it is indicated 'Running BEGIN
PROGRAM' and nothing happens.... Can anyone help me any further? Why is this very very simple program
not come to its end?? Do I have to install other things? Do I have to load first the SPSS
library in R? Karin |
|
Dear all,
I'm working with a data file containing many variables twice: the original 5 point Likert scales as well as dichotomized versions ending with an S. This precludes using 'to' in variable lists (e.g. V1 to V10). Since I'm not interested in any dichotomized variables, I'd like to delete all variables ending with an S. Does anybody know a trick in order to accomplish this? Lots of TIA and kind regards, Ruben Example: V65_3 V65_3S V65_4 V65_4S V65_5 V65_5S V65_6 V65_6S V65_7 V65_7S V65_8 V65_8S V65_9 V65_9S V65_10 V65_10S V65_11 V65_11S V65_12 V65_12S V65_13 V65_13S Express yourself instantly with MSN Messenger! MSN Messenger |
|
The following
short Python program will do this. The VariableDict object allows regular
expression patterns to be used to select the variables. The matches are not
case sensitive. data list free/x
xs y ys. begin data. 1 2 3 4 end data. begin program. import spss, spssaux vardict = spssaux.VariableDict(pattern=".*S$") spss.Submit("delete
variables " + " ".join(vardict.variables)) end program. HTH, Jon Peck From: SPSSX(r)
Discussion [mailto:[hidden email]] On
Behalf Of Ruben van den Berg Dear all, Express yourself instantly with MSN Messenger! MSN Messenger |
|
In reply to this post by Ruben Geert van den Berg
Just in case you don't Python yet (as it happens to me), here is a more
classic approach to the task. It works with the names you provided (it will fail if there are "S" inside the original variable names, the ones that sould be preserved): * Sample dataset *. DATA LIST LIST/V65_3 V65_3S V65_4 V65_4S V65_5 V65_5S V65_6 V65_6S V65_7 V65_7S V65_8 V65_8S V65_9 V65_9S V65_10 V65_10S V65_11 V65_11S V65_12 V65_12S V65_13 V65_13S. BEGIN DATA 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 END DATA. DATASET NAME OriginalData. DATASET COPY NewData . DATASET ACTIVATE NewData. FLIP VARIABLES=ALL. DATASET NAME FlipData. SELECT IF (RINDEX(CASE_LBL,'S') GT 0). DO IF $CASENUM EQ 1. - WRITE OUTFILE 'C:\temp\DeleteS.sps' /'DELETE VARIABLES'. END IF. WRITE OUTFILE 'C:\temp\DeleteS.sps'/' ' CASE_LBL. CACHE. EXE. DATASET ACTIVATE NewData. DATASET CLOSE FlipData. INCLUDE 'C:\temp\DeleteS.sps'. At the end, you will have your original data untouched (OriginalData) and a copy of the dataset (NewData) without the recoded variables. HTH, Marta GarcĂa-Granero Ruben van den Berg wrote: > I'm working with a data file containing many variables twice: the > original 5 point Likert scales as well as dichotomized versions ending > with an S. This precludes using 'to' in variable lists (e.g. V1 to > V10). Since I'm not interested in any dichotomized variables, I'd like > to delete all variables ending with an S. Does anybody know a trick in > order to accomplish this? > > > Example: > > V65_3 > V65_3S > V65_4 > V65_4S > V65_5 > V65_5S > V65_6 > V65_6S > V65_7 > V65_7S > V65_8 > V65_8S > V65_9 > V65_9S > V65_10 > V65_10S > V65_11 > V65_11S > V65_12 > V65_12S > V65_13 > V65_13S ===================== 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 Ruben Geert van den Berg
This would work with the kind of example you gave. Open a new instance of SPSS. Copy the syntax below to a syntax file. select and run the syntax up to the word "original". follow the steps in the comments. Compare it to the green text that was pasted from the tosort dataset. Select and run the rest of the syntax. open the "original" window and look at it. data list list/id (f2) place (a5) V65_3 V65_3S junk1 V65_4 V65_4S V65_5 V65_5S junk2 V65_6 V65_6S V65_7 V65_7S V65_8 V65_8S V65_9 V65_9S V65_10 V65_10S V65_11 V65_11S V65_12 V65_12S V65_13 V65_13S (24f1) a b c d e (5a1). begin data end data. dataset name original. *the syntax below here is one approach. dataset copy tosort. * click <window>. * click <tosort>. * click <variable view>. * right click <name>. * click <sort ascending>. * use mouse to select list(s) of variables you want to delete. * copy and paste the text the into the syntax window. dataset activate original. delete vars V65_10S V65_11S V65_12S V65_13S V65_3S V65_4S V65_5S V65_6S V65_7S V65_8S V65_9S . * save as a new file. Ruben van den Berg wrote: Dear all,
Art Kendall
Social Research Consultants |
|
In reply to this post by Ruben Geert van den Berg
I was thinking of the solution below but I agree that a regular expression is much more powerful. But why is pattern=".*S$" not case-sensitive? I thought pattern=".*S|s$" would be needed or re.IGNORECASE or something like that.
Cheers!! Albert-Jan import spssaux, spss flush = [var for var in spssaux.GetVariableNamesList() if var.lower().endswith("s")] if flush: spss.Submit("add files / file = * / drop = %s." % ' '.join(flush)) --- On Mon, 3/16/09, Peck, Jon <[hidden email]> wrote: > From: Peck, Jon <[hidden email]> > Subject: Re: Delete all variables in my data that end with S (e.g. V140_1S) > To: [hidden email] > Date: Monday, March 16, 2009, 4:09 PM > > > > > > > > > > > > > > > > > The following > short Python program will do this. The VariableDict > object allows regular > expression patterns to be used to select the variables. > The matches are not > case sensitive. > > > > data list free/x > xs y ys. > > begin data. > > 1 2 3 4 > > end data. > > > > begin program. > > import spss, spssaux > > vardict = > spssaux.VariableDict(pattern=".*S$") > > > spss.Submit("delete > variables " + " > ".join(vardict.variables)) > > end program. > > > > HTH, > > Jon Peck > > > > > > > > > > > > From: SPSSX(r) > Discussion [mailto:[hidden email]] On > Behalf Of Ruben van den Berg > > Sent: Monday, > March 16, 2009 8:46 > AM > > To: > [hidden email] > > Subject: > [SPSSX-L] Delete all > variables in my data that end with S (e.g. > V140_1S) > > > > > > Dear all, > > > > I'm working with a data file containing many variables > twice: the original 5 > point Likert scales as well as dichotomized > versions ending with an > S. This precludes using 'to' in variable lists > (e.g. V1 to V10). Since I'm not > interested in any dichotomized variables, I'd like to > delete all variables > ending with an S. Does anybody know a trick in order to > accomplish this? > > > > Lots of TIA and kind regards, > > > > Ruben > > > > Example: > > > > V65_3 > > V65_3S > > V65_4 > > V65_4S > > V65_5 > > V65_5S > > V65_6 > > V65_6S > > V65_7 > > V65_7S > > V65_8 > > V65_8S > > V65_9 > > V65_9S > > V65_10 > > V65_10S > > V65_11 > > V65_11S > > V65_12 > > V65_12S > > V65_13 > > V65_13S > > > > > > > > Express > yourself instantly with MSN Messenger! MSN > Messenger > > > > > > > ===================== 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 |
|
That's because the IGNORECASE flag is set internally in the VariableDict code in applying the pattern. Without that, it would be case sensitive. (You can look at the code in makeVariableFilter in spssaux to see this.)
-----Original Message----- From: Albert-jan Roskam [mailto:[hidden email]] Sent: Monday, March 16, 2009 10:44 AM To: [hidden email]; Peck, Jon Subject: Re: Delete all variables in my data that end with S (e.g. V140_1S) I was thinking of the solution below but I agree that a regular expression is much more powerful. But why is pattern=".*S$" not case-sensitive? I thought pattern=".*S|s$" would be needed or re.IGNORECASE or something like that. Cheers!! Albert-Jan import spssaux, spss flush = [var for var in spssaux.GetVariableNamesList() if var.lower().endswith("s")] if flush: spss.Submit("add files / file = * / drop = %s." % ' '.join(flush)) --- On Mon, 3/16/09, Peck, Jon <[hidden email]> wrote: > From: Peck, Jon <[hidden email]> > Subject: Re: Delete all variables in my data that end with S (e.g. V140_1S) > To: [hidden email] > Date: Monday, March 16, 2009, 4:09 PM > > > > > > > > > > > > > > > > > The following > short Python program will do this. The VariableDict > object allows regular > expression patterns to be used to select the variables. > The matches are not > case sensitive. > > > > data list free/x > xs y ys. > > begin data. > > 1 2 3 4 > > end data. > > > > begin program. > > import spss, spssaux > > vardict = > spssaux.VariableDict(pattern=".*S$") > > > spss.Submit("delete > variables " + " > ".join(vardict.variables)) > > end program. > > > > HTH, > > Jon Peck > > > > > > > > > > > > From: SPSSX(r) > Discussion [mailto:[hidden email]] On > Behalf Of Ruben van den Berg > > Sent: Monday, > March 16, 2009 8:46 > AM > > To: > [hidden email] > > Subject: > [SPSSX-L] Delete all > variables in my data that end with S (e.g. > V140_1S) > > > > > > Dear all, > > > > I'm working with a data file containing many variables > twice: the original 5 > point Likert scales as well as dichotomized > versions ending with an > S. This precludes using 'to' in variable lists > (e.g. V1 to V10). Since I'm not > interested in any dichotomized variables, I'd like to > delete all variables > ending with an S. Does anybody know a trick in order to > accomplish this? > > > > Lots of TIA and kind regards, > > > > Ruben > > > > Example: > > > > V65_3 > > V65_3S > > V65_4 > > V65_4S > > V65_5 > > V65_5S > > V65_6 > > V65_6S > > V65_7 > > V65_7S > > V65_8 > > V65_8S > > V65_9 > > V65_9S > > V65_10 > > V65_10S > > V65_11 > > V65_11S > > V65_12 > > V65_12S > > V65_13 > > V65_13S > > > > > > > > Express > yourself instantly with MSN Messenger! MSN > Messenger > > > > > > > ===================== 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 |
