I had a question on my questionnaire that asked living arrangements and if participants selected option B or C they got asked another question. All data on SPSS for those who selected A is coming up as a '.' as they obviously did not get to see the next question.
Should I just write all missing answers as a number e.g. 3 and then label the number 3 as 'ignore' or 'NA' in variable view or is there something else I can do?
Please note I'm a 3rd year university student who is awful at SPSS so I don't know all the technical terms! Hope someone can help.
Thanks.
As mentioned in the comments, it really depends on how you intend on using your data. That said, one approach is to assign values to your system missings to increase flexibility. I'll riff an example based on your description.
Q1) Please describe your living arrangements.
a. I live alone.
b. I live with family/roommates and am the head of household.
c. I live with family/roommates, but am not the head of household.
[If Q1=a Then skip]
Q2) How many other members, excluding yourself, do you live with?
a. 1 b. 2 c. 3 d. 4 or more
Q3) Are any of these [Q2 count] members non-family roommates?
a. Yes
b. No
Since Q2 is a count of people in household (excluding self), you might recode those living on their own to actually answer the question.
RECODE Q2 (SYSMIS=0).
EXE .
Or if there was a need to differentiate (either because not all SYSMIS should be 0 or because you want to keep track of why they are 0). In this case you can toggle those missing values on/off as needed.
IF (Q1='a') Q2=0.001 .
EXE .
ADD VALUE LABELS Q2 .001 'Lives Alone' .
MISSING VALUES Q2 (.001) .
For Q3, it really is more of an N/A. In that case you might choose an arbitrary value (-1, 99, etc) for tracking purposes and always keep those missing values set.
If (Q1='a' AND Q3=$SYSMIS) Q3=99 .
EXE .
ADD VALUE LABELS Q3 99 'N/A, lives alone' .
MISSING VALUES Q3 (99) .
Related
In our schools, we have books of the same title by the same author but different ISBN #s. I am working on an inventory list so that we can scan the different ISBNs and then find out what is on hand for a title.
Here is my working spreadsheet demo. The live version will be separated (columns A-D by data that comes in on another sheet (possibly by Google Forms) and a separate sheet (F-J) that does all the math. For convenience / testing, they are all on one sheet.
Essentially, in column F, I would like to sum all the quantities in A where the ISBN's in C match any of the values of G and place it in F.
The formula I am using in F doesn't seem to completely work:
=SUMIF(C:C,arrayformula(split(G2,",")),A:A)
It captures the first match but ignores / doesn't loop over the rest. I have looked at Sumifs and Match and I cannot seem to get any closer with the syntax. I would greatly appreciate if anyone can help me solve this dilemma.
Additionally, I know how to do this with a custom script but I need to avoid that as end users break things for one reason or another and I can't handle the debugging load the way this could possibly be deployed.
Thanks in advance for anyone willing to take a look at this!
~Allan
Try in F2
=sum(query(A:D,"select A where C matches '"& textjoin("|",,split(G2,",")) &"' ",0))
delete everything in F2:F & J2:J and use F2:
=INDEX(IF(G2:G="",,MMULT(IFERROR(VLOOKUP(SPLIT(G2:G, ","), {C:C, A:A}, 2, ), 0),
SEQUENCE(COLUMNS(SPLIT(G2:G, ",")), 1, 1, ))))
in J2 use:
=ARRAYFORMULA(IF(G2:G="",,F2:F*I2:I))
What is wrong with my formula? Getting #ERROR! message. The 3.5x9.125 and so on is a paper size, and 0-32 and so on is print area per sq/in. I am trying to make Q4 determine the paper size based on the Q3 option selected from a pull down list.
If I understood the assignment this should help. =IF(or(B48<32,B48=32),"3.5x9.125",IF(or(B48=93,B48=33,and(B48>33,B48<93)),"8.5x11",IF(or(B48=94,B48=187,and(B48>94,B48<187)),"11x17")))
I am working with data from a multiple choice survey question. Survey respondents were able to select options A, B, C and/or D. The data file simply lists the response(s) they chose, with no spaces, commas or semicolons in between. For example, the data for a respondent who selected options A and C would simply be "AC"; the data for a respondent who selected options A, B, C and D would be "ABCD".
I need to create 4 new variables that indicate whether the respondent selected each of the 4 choices (i.e., if they didn't select A then A = 0; if they did select A then A = 1, and so on). How do I do this with my string data, given that there are no spaces or commas between the responses? I would greatly appreciate your help!
The OP correctly hinted at the answer in his comment, but for the sake of clarity, and in the spirit of Stack Overflow, here is the full answer:
Assuming multi_answer is the string variable holding the survey answer:
DO REPEAT answers="A" "B" "C" D"
/vars=var1 to var4.
COMPUTE vars=0.
if CHAR.INDEX(multi_answer,answers)<>0 vars=1.
END REPEAT.
EXECUTE.
Edit:
As per eli-k's comment, a more synthetic way is to use this inside the DO REPEAT END REPEAT structure:
compute vars=char.index(multi_answer,answers)>0.
so you don't need the compute vars=0.
End of Edit.
Both codes will create 4 variables (var1 var2 var3 var4) with values of 0 or 1, as described in the question.
IBM SPSS Official help on the string functions (including CHAR.INDEX function) : https://www.ibm.com/support/knowledgecenter/pl/SSLVMB_23.0.0/spss/base/syn_transformation_expressions_string_functions.html
Also a possible duplicate of this :):
SPSS: how to find text in text?
Having a bit of an issue and unsure if it's actually possible to do.
I'm working on a file that I will enter target progression vs actual target reporting the % outcome.
PAGE 1
¦NAME ¦TAR 1 %¦TAR 2 %¦TAR 3 %¦TAR 4 %¦OVERALL¦SUB 1¦SUB 2¦SUB 3¦
¦NAME1¦ 114%¦ 121%¦ 100%¦ 250%¦ 146%¦ 2¦ 0¦ 0%¦
¦NAME2¦ 88%¦ 100%¦ 90%¦ 50%¦ 82%¦ 0¦ 1¦ 0%¦
¦NAME3¦ 82%¦ 54%¦ 64%¦ 100%¦ 75%¦ 6¦ 6¦ 15%¦
¦NAME4¦ 103%¦ 64%¦ 56%¦ 43%¦ 67%¦ 4¦ 4¦ 24%¦
¦NAME5¦ 87%¦ 63%¦ 89%¦ 0%¦ 60%¦ 3¦ 2¦ 16%¦
Now I already have it sorting all rows by the Overall % column so I can quickly see at a glance but I am creating a second page that I need to reference points.
So on the second page I would like to somehow sort and reference different columns for example
PAGE 2
TOP TAR 1¦Name of top %¦Top %¦
TOP TAR 2¦Name of top %¦Top %¦
Is something like this possible to do?
Essentially I'm creating an Employee of the Month form that automatically works out who has topped what.
I'm willing to drop a paypal donation for whoever can figure this out for me as I've been doing it manually every month and would appreciate the time saved
I don't think a complicated array formula is necessary for this - I am suggesting a fairly standard Index/Match approach.
First set up the row titles - you can just copy and transpose them from Page 1, or use a formula in A2 of Page 2 like
=transpose('Page 1'!B1:E1)
The use them in an index/match to get the data in the corresponding column of the main sheet and find its maximum (in C2)
=max(index('Page 1'!A:E,0,match(A2,'Page 1'!A$1:E$1,0)))
Finally look up the maximum in the main sheet to find the corresponding name:
=index('Page 1'!A:A,match(C2,index('Page 1'!A:E,0,match(A2,'Page 1'!A$1:E$1,0)),0))
If you think there could be a tie for first place with two or more people getting the same score, you could use a filter to get the different names:
So if the max score is in B8 this time (same formula)
=max(index('Page 1'!A:E,0,match(A8,'Page 1'!A$1:E$1,0)))
the different names could be spread across the corresponding row using transpose (in C8)
=ArrayFormula(TRANSPOSE(filter('Page 1'!A:A,index('Page 1'!A:E,0,match(A8,'Page 1'!A$1:E$1,0))=B8)))
I have changed the test data slightly to show these different scenarios
Results
I have a relatively simple report that is 'working'.
It has a main Group based on an Expression - with one sort in the Group - and then another 'Group' named 'Details' under that in the Row Groups pane.
The Main Group is repeating itself for no reason that I can figure.
I expect that if there is a Group called 'A' - then all the Detail rows in that Group will display till the next Group - right?
Like this:
A
Bob 1 Texas
Jane 2 California
Devin 4 New York
B
Jack 3 Texas
Mary 6 Maine
Peter 5 Michigan
C
. . .
Instead, the report is doing something like this:
A
Bob 1 Texas
Jane 2 California
A
Devin 4 New York
B
Jack 3 Texas
B
Mary 6 Maine
Peter 5 Michigan
C
. . .
If I delete the Details Group I lose some data & the report goes from 5 pages [57 detail recs] to about two pages.
If I delete the Main Group as well - I go down to just one record in the entire report.
I need to keep all the data that is on the report - but have it Group correctly by the Main Group [without repeats of the Group Header] and then within each group - sort by a couple of different fields.
Any idea how I should go about Troubleshooting the issue?
Thanks!!
It looks like there might be something that is Grouping your detail. Make sure that there isn't any grouping on it.
If you can't figure it out, try creating a new one using your old one as a template. I've wasted hours trying to figure out what an issue is but creating a new matrix just takes a few minutes.
I had copied all the cells from the old matrix to a new one I had created and it worked as the first one should have.
I've had this happen a few times and have since given up on trying to figure out why something doesn't work.
I found the problem.
The 'IIF . . . ' Expression for the Group By and the Expression in the Group Header had different field names in the 'False' argument of the two expressions. So the report was GROUPING by one field - but DISPLAYING another field as the Group Header.
I have never done something like that and I can't imagine why I ever WOULD . . . and perhaps that is why I only stumbled on the anomaly because I was copying the two expressions into Notepad to recreate the Matrix and then noticed the difference.
The two field names in the 'False' arguments of the IIF expressions are quite similar - and that was an added reason that it was almost 'camouflaged'.
This is resolved.
Thanks #Hannover Fist! Appreciate that. To copy all the cells, can you just 'lasso' them with the mouse and then Ctrl + C . . . & then create a new Matrix and Ctrl + V? I was on the verge of just re-creating the Matrix.