In one of the datasets I am regularly working with there are more than 600 variables covering population screenings from 1986 and onwards. Most variables have been used throughout the whole period, but there are also those which are specific for one or a limited number of screening rounds.
Now I need to find those variables which were used in the last screening from 2014. One way could be to use a custom attribute (scr_yr) which has been used to mark all variables with the years they have been used. The syntax for one of the variables (seqno) looks like this: VARIABLE ATTRIBUTE VARIABLES=seqno ATTRIBUTE=scr_yr[1]('1986') scr_yr[2]('1990') scr_yr[3]('1994') scr_yr[4]('1999') scr_yr[5]('2004') scr_yr[6]('2009') scr_yr[7]('2014'). I tried the GATHERMD extension, but as stated in the help file, "If the attribute is an array, only the first value is included". I would like to see the *last* attribute. Any suggestions? Robert ===================== 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
Robert Lundqvist
|
The CODEBOOK procedure can display custom attributes, and you can turn off the other output from it. If you need to do something programmatic with the attribute, tell me more, and we can work something out. On Wed, Jun 22, 2016 at 5:19 AM, Robert Lundqvist <[hidden email]> wrote: In one of the datasets I am regularly working with there are more than 600 variables covering population screenings from 1986 and onwards. Most variables have been used throughout the whole period, but there are also those which are specific for one or a limited number of screening rounds. |
In reply to this post by Robert L
I thought of a way that will work very easily. Use the SPSSINC SELECT VARIABLES extension command to create a macro listing only variables that have the desired attribute somewhere in the array. Then use that with SAVE /KEEP !macro or similar. Here's an example SPSSINC SELECT VARIABLES MACRONAME="!just2014" /ATTRHASALL scr_yr /ATTRVALUES NAME=scr_yr VALUE = '2014' . On Wed, Jun 22, 2016 at 5:19 AM, Robert Lundqvist <[hidden email]> wrote: In one of the datasets I am regularly working with there are more than 600 variables covering population screenings from 1986 and onwards. Most variables have been used throughout the whole period, but there are also those which are specific for one or a limited number of screening rounds. |
If you want to produce a usable list of variable names, here’s a modified version of some Python code Jon Peck wrote for me to find variables with specified unique value and value label combinations. I’ve no idea if it will work on your data, but I have assumed from the original query that there is a value 7 associated with the label “2014”. * Encoding: UTF-8. begin program. # find specific value label and code combinations import spss # change as needed using value and label pairs # Note that numerical values must be specified with a decimal point targets = [(7.0), ("2014")] spss.StartDataStep() ds = spss.Dataset() for v in ds.varlist: for val, vl in v.valueLabels.data.iteritems(): if (val, vl) in targets: print v.name, "\t",val, vl spss.EndDataStep() end program. If it works, the spv output table will contain a list of the variables with value 7 and value label “2014”. Copying to Word produces a single line, but copying to Excel first keeps the variable names and values in column format, sometimes in a single column, sometimes in two. (No idea why, but Jon will). The value “2014” can then be eliminated using Ctrl+H leaving a list of variables which can then be copied direct into SPSS syntax. If it doesn’t work in Excel, the column(s) can be copied into Notepad instead. I’ve used it for single values, pairs and even threesomes. It has literally saved me months of needle-in-haystack searches through a cumulative file for the British Social Attitudes survey 1983-2014 with 10,765 variables. (See: http://surveyresearch.weebly.com/british-social-attitudes1.html ) Give that man a medal! John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jon Peck I thought of a way that will work very easily. Use the SPSSINC SELECT VARIABLES extension command to create a macro listing only variables that have the desired attribute somewhere in the array. Then use that with SAVE /KEEP !macro or similar. Here's an example SPSSINC SELECT VARIABLES MACRONAME="!just2014" /ATTRHASALL scr_yr /ATTRVALUES NAME=scr_yr VALUE = '2014' . On Wed, Jun 22, 2016 at 5:19 AM, Robert Lundqvist <[hidden email]> wrote:
-- Jon K Peck ===================== 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 |