I have several autoscripts that I have used in SPSS version 15 and before to hide output items in the Viewer when a particular procedure is run. For example, the following little script hides the case processing summary generated by the EXAMINE command:
Sub Explore_Table_CaseProcessingSummary_Create(objTable As Object, objOutputDoc As Object, lngIndex As Long) Dim objitem As ISpssItem Set objitem = objOutputDoc.Items.GetItem(lngIndex) objitem.Visible = False End Sub How do I have to modify this procedure so that it will run under version 16 and above? Is it advisable to to continue using Basic scripting (under Windows), or should I better get acquainted with Python? Thanks, Andreas Voelp |
Administrator
|
Hi Andreas. You can use OMS to exclude the case processing summary from the output viewer.
OMS /SELECT TABLES /IF COMMANDS=['Explore'] SUBTYPES=['Case Processing Summary'] /DESTINATION VIEWER=NO. IIRC, you can have a start-up script call a syntax file; so that would be one way to go. HTH.
--
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/). |
In reply to this post by Frank Furter
See the Scripting topic in the help. Pre-16
autoscripts require a minor modification. Each autoscript is now
a separate file, and you need to add one line of code to get the script
arguments. Autoscripts are now enabled via the Scripting tab in Edit>Options.
You will also find that it is now much easier to debug autoscripts,
because they can also be run as regular scripts.
You can also use the SPSSINC MODIFY OUTPUT extension command to change visibility of objects ex post according to various criteria, and you can, of course, use OMS to suppress various objects a priori. Jon Peck Senior Software Engineer, IBM [hidden email] 312-651-3435 From: Andreas Voelp <[hidden email]> To: [hidden email] Date: 11/23/2010 01:54 PM Subject: [SPSSX-L] Autoscripting advice (recent SPSS versions vs. v15 and before) Sent by: "SPSSX(r) Discussion" <[hidden email]> I have several autoscripts that I have used in SPSS version 15 and before to hide output items in the Viewer when a particular procedure is run. For example, the following little script hides the case processing summary generated by the EXAMINE command: Sub Explore_Table_CaseProcessingSummary_Create(objTable As Object, objOutputDoc As Object, lngIndex As Long) Dim objitem As ISpssItem Set objitem = objOutputDoc.Items.GetItem(lngIndex) objitem.Visible = False End Sub How do I have to modify this procedure so that it will run under version 16 and above? Is it advisable to to continue using Basic scripting (under Windows), or should I better get acquainted with Python? Thanks, Andreas Voelp -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Autoscripting-advice-recent-SPSS-versions-vs-v15-and-before-tp3277498p3277498.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 |
... and which line would that be in the sample autoscript above? According to the Help on legacy autoscripts you have to "Use the scriptContext object (always available) to get the values required by the autoscript, such as the output item that triggered the autoscript." (I think this is what you were referring to), but I couldn't figure out how to do that. As you may guess from my question I am not exactly a scripting expert (yet), but I think it's really worthwhile. For someone like me who hasn't done much scripting before, would you still recommend Basic scripting, or should I better go for Python right from the start (e.g., because SPSS may discontinue Basic support at some time in the future anyway?)? And yes, using the OMS instead of scripting to automatically hide items in the output would certainly be a good and easy to use alternative (but nevertheless I would like to understand how to do that with an autoscript ... ). Andreas |
Andreas
You need to add a special line in the declarations section to point the script at Global.wwd: For example if Global.wwd is in the directory C:\Program Files\SPSSInc\PASWStatistics18\Samples you add the comment: '#Uses "C:\Program Files\SPSSInc\PASWStatistics18\Samples\Global.wwd" And yes, it is a COMMENT, preceded by the single quote. Garry Gelade Business Analytic Ltd. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Andreas Voelp Sent: 24 November 2010 07:26 To: [hidden email] Subject: Re: Autoscripting advice (recent SPSS versions vs. v15 and before) Jon K Peck wrote: > > ... and you need to add one line of code to get the script arguments. ... and which line would that be in the sample autoscript above? According to the Help on legacy autoscripts you have to "Use the scriptContext object (always available) to get the values required by the autoscript, such as the output item that triggered the autoscript." (I think this is what you were referring to), but I couldn't figure out how to do that. As you may guess from my question I am not exactly a scripting expert (yet), but I think it's really worthwhile. For someone like me who hasn't done much scripting before, would you still recommend Basic scripting, or should I better go for Python right from the start (e.g., because SPSS may discontinue Basic support at some time in the future anyway?)? And yes, using the OMS instead of scripting to automatically hide items in the output would certainly be a good and easy to use alternative (but nevertheless I would like to understand how to do that with an autoscript ... ). Andreas -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Autoscripting-advice-recent-SP SS-versions-vs-v15-and-before-tp3277498p3277997.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 |
In reply to this post by Frank Furter
Jon Peck Senior Software Engineer, IBM [hidden email] 312-651-3435 From: Andreas Voelp <[hidden email]> To: [hidden email] Date: 11/24/2010 12:35 AM Subject: Re: [SPSSX-L] Autoscripting advice (recent SPSS versions vs. v15 and before) Sent by: "SPSSX(r) Discussion" <[hidden email]> Jon K Peck wrote: > > ... and you need to add one line of code to get the script arguments. ... and which line would that be in the sample autoscript above? According to the Help on legacy autoscripts you have to "Use the scriptContext object (always available) to get the values required by the autoscript, such as the output item that triggered the autoscript." (I think this is what you were referring to), but I couldn't figure out how to do that. >>>Here is an example from the scripting help. The scriptContext object has three methods. You may not need all of them. For your particular script, in fact, you need only one. Dim objTable As ISpssItem 'Get the output item that triggered the autoscript Set objTable = scriptContext.GetOutputItem You can also get the output document and the index of the output item. Your original script is Sub Explore_Table_CaseProcessingSummary_Create(objTable As Object, objOutputDoc As Object, lngIndex As Long) Dim objitem As ISpssItem Set objitem = objOutputDoc.Items.GetItem(lngIndex) objitem.Visible = False End Sub so the revised version would be Sub Main() Dim objitem As ISpssItem Set objitem = scriptContext.GetOutputItem() objitem.Visible = False End Sub You would install this on the Scripts tab of Edit>Options for the particular command and table type you want to hide. The scripting tab shows a list of all the table types that can be produced for each command. Be sure to check the enable autoscripting box and set the type to Basic. As you may guess from my question I am not exactly a scripting expert (yet), but I think it's really worthwhile. For someone like me who hasn't done much scripting before, would you still recommend Basic scripting, or should I better go for Python right from the start (e.g., because SPSS may discontinue Basic support at some time in the future anyway?)? >>> If you are starting to learn a scripting language, I would definitely recommend Python over Basic. This is not because Basic is going to be discontinued but rather because Python is a much better language, and it can be used for programmability as well as scripting. We don't plan to enhance Basic scripting going forward, however. HTH, Jon Peck And yes, using the OMS instead of scripting to automatically hide items in the output would certainly be a good and easy to use alternative (but nevertheless I would like to understand how to do that with an autoscript ... ). Andreas -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Autoscripting-advice-recent-SPSS-versions-vs-v15-and-before-tp3277498p3277997.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 |
In reply to this post by Frank Furter
I'm sorry if this has been asked before or is completely obvious - I couldn't find an answer easily online.
I'm running SPSS v18 and would like a codebook that I can put into excel so each line has a variable in it. Ideally, I'd like to take the output below and put it in an excel document so the variable name is in the first column, the label is in the second column, etc. The most important part to me is the Variable name and Variable label being in columns 1 & 2, as we can copy and paste the values and value labels. Does anyone have any suggestions of how to do this? Thank you so much!! See below for an example. Bethany Desired output in Excel: VARIABLE NAME VARIABLE LABEL Values SAMPLMAJ Major sample identification (aka sample) 1 Main RDD; 2 Sibling; 3 Twin; 4 City Oversamples Current output in SPSS 18.
|
I've never actually tried this, but is there any reason why you can't
re-arrange the columns in the data editor and copy part or all of the matrix across to Excel,or even copy across without re-arranging and then delete the columns you don't want? I must try something for the SPSS 18 tutorials on my site. John Hall [hidden email] http://surveyresearch.weebly.com ----- Original Message ----- From: Bethany Cockburn To: [hidden email] Sent: Wednesday, November 24, 2010 4:56 PM Subject: Codebook Values next to Variables I'm sorry if this has been asked before or is completely obvious - I couldn't find an answer easily online. I'm running SPSS v18 and would like a codebook that I can put into excel so each line has a variable in it. Ideally, I'd like to take the output below and put it in an excel document so the variable name is in the first column, the label is in the second column, etc. The most important part to me is the Variable name and Variable label being in columns 1 & 2, as we can copy and paste the values and value labels. Does anyone have any suggestions of how to do this? Thank you so much!! See below for an example. Bethany Desired output in Excel: VARIABLE NAME VARIABLE LABEL Values SAMPLMAJ Major sample identification (aka sample) 1 Main RDD; 2 Sibling; 3 Twin; 4 City Oversamples Current output in SPSS 18. SAMPLMAJ Value Standard AttributesPosition3 LabelMajor sample identification (aka Sample) TypeNumeric FormatF1 MeasurementNominal RoleInput Valid Values1MAIN RDD 2SIBLING 3TWIN 4CITY OVERSAMPLES ===================== 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 Bethany Cockburn
Tried playing around by opening one of
the *.sav files from my training materials and also a blank Excel file then
tried highlighting and copying columns from the data edoitor to Excel.
Highlighting all three didn't work: [CTRL] C just copies the
screenshot into Excel, but if you copy one column at a time it seems to work.
OE wouldn't let me copy anything except the first screen shot, but I found a
workaround by dumping them to Word and then scanning the whole document, as
below.
<IMG src="file://C:\DOCUME~1\Owner\LOCALS~1\Temp\msohtml1\01\clip_image002.jpg" width=623 height=412 v:shapes="_x0000_i1025"> <IMG src="file://C:\DOCUME~1\Owner\LOCALS~1\Temp\msohtml1\01\clip_image004.jpg" width=623 height=412 v:shapes="_x0000_i1030">
<IMG src="file://C:\DOCUME~1\Owner\LOCALS~1\Temp\msohtml1\01\clip_image006.jpg" width=624 height=368 v:shapes="_x0000_i1026"> <IMG src="file://C:\DOCUME~1\Owner\LOCALS~1\Temp\msohtml1\01\clip_image008.jpg" width=623 height=412 v:shapes="_x0000_i1031"> <IMG src="file://C:\DOCUME~1\Owner\LOCALS~1\Temp\msohtml1\01\clip_image010.jpg" width=624 height=368 v:shapes="_x0000_i1027"> <IMG src="file://C:\DOCUME~1\Owner\LOCALS~1\Temp\msohtml1\01\clip_image012.jpg" width=623 height=412 v:shapes="_x0000_i1028"> <IMG src="file://C:\DOCUME~1\Owner\LOCALS~1\Temp\msohtml1\01\clip_image014.jpg" width=624 height=368 v:shapes="_x0000_i1029"> Is this the sort of thing you want?
|
Hi John (and others)!
You could write basic syntax that will approach the result desired by the OP but this one is long and clumsy. I've no clue why anyone would want to do this but that's none of my business. HTH, Ruben *Syntax. dataset close all. cd'C:\Program Files\SPSSInc\PASWStatistics18\Samples\English'. get file '1991 U.S. General Social Survey.sav'. dataset name d1. * OMS. DATASET DECLARE vallabs. OMS /SELECT TABLES /IF COMMANDS=['File Information'] SUBTYPES=['Variable Values'] /DESTINATION FORMAT=SAV NUMBERED=TableNumber_ OUTFILE='vallabs' VIEWER=NO /TAG='vallabs'. * OMS. DATASET DECLARE varlabs. OMS /SELECT TABLES /IF COMMANDS=['File Information'] SUBTYPES=['Variable Information'] /DESTINATION FORMAT=SAV NUMBERED=TableNumber_ OUTFILE='varlabs' VIEWER=NO /TAG='varlabs'. display dictionary. omsend tag=['varlabs']. omsend tag=['vallabs']. dataset activate vallabs. delete variables TableNumber_ to Label_. sort cases by var1. CASESTOVARS /id=var1. string Value_labels(a1000). do repeat val=var2.1 to var2.10/lab=label.1 to label.10. do if mis(val)=0 and lab ne ''. compute Value_labels=ltr(concat(rtr(Value_labels),';',ltr(rtr(str(val,f2)))," ",rtr(lab))). end if. end repeat print. compute Value_labels=substr(Value_labels,2). sort cases by var1. dataset activate varlabs. sort cases by var1. match files file vallabs /file varlabs /by var1 /keep var1 Label Value_labels. dataset close all. exe. rename variables (var1 label=Variable Variable_label). save translate outfile 'Dict_sheet.xls' /type xls /version 8 /fieldnames /replace. Date: Thu, 25 Nov 2010 14:15:39 +0100 From: [hidden email] Subject: Re: Codebook Values next to Variables (2) To: [hidden email] Tried playing around by opening one of
the *.sav files from my training materials and also a blank Excel file then
tried highlighting and copying columns from the data edoitor to Excel.
Highlighting all three didn't work: [CTRL] C just copies the
screenshot into Excel, but if you copy one column at a time it seems to work.
OE wouldn't let me copy anything except the first screen shot, but I found a
workaround by dumping them to Word and then scanning the whole document, as
below.
Doesn't work, but [ctrl]c and [ctrl v] do this, one column at a time.
Is this the sort of thing you want?
|
Free forum by Nabble | Edit this page |