Posts filed under 'Questions and answers'
One of the many questions we got the last few days was from Dana. Dana asked us a question about combining two variables into one:
“Hello, I need to essentially combine two variables that have been
standardized into one new variable.Â Data that is present in one variable
is missing on the other and vice versa.Â I tried making a new variable and
then recoding missing data so it would pull in the values from the other
variable.Â Can you only recode missing values into numbers, or can I pull
an entirely different variable into it?Â Basically, how do I combine two
variables into one?Â Is there an easier way? Thanks!”
Well, there certainly is an easier way to combine two variables. Let’s assume you have the variables VAR00001 and VAR00002 which you want to combine into one new variable. We also assume that they do not have overlapping records, with which I mean that there is no record which has a value in both variables. To combine the two, you can use the following SPSS Syntax:
COMPUTE NEW_VAR = VAR00001.
IF (VAR00002 = 4) NEW_VAR = 4 .
IF (VAR00002 = 5) NEW_VAR = 5 .
IF (VAR00002 = 6) NEW_VAR = 6 .
The first part (COMPUTE NEW_VAR = VAR00001.) creates the new variable and copies all values fromÂ VAR00001 into the new variable. The second part copies the values from VAR00002 to the new variable, for the values 4, 5 and 6. Very probably, your second variable contains different values, so adjust the Syntax to your needs.
April 10th, 2007
This week Eamonn send us the following question about the Compute function:
When using transfor/compute – say to create a construct from a set of Likert
Scale items – does SPSS save the formula used to create the new variable, or
is it lost once you compute?
SPSS does not save the formula in your data file. It does keep the formula in mind if you keep SPSS open. So if you want to use the same formula again, but than with different variables for example, you can open the Compute screen again, and there your old formula is. But if you close SPSS and open it again, the formula will be gone.
January 19th, 2007
From Lawrence, Will, Mark and Andris (SPSSlog.com) a Merry Christmas and happy 2007 for all of our visitors! Since the start of SPSSlog, we’ve answered over 200 questions on SPSS… we hope to help even more SPSS users in next year.
Technorati: Posts that contain Happy Holidays per day for the last 30 days.
If you need something to do during your time off, try out theÂ great online graph service Swivel, or try making the coolest SQUARE PIE-CHART graphs with SPSS! Post all your creations in our comments…
Our new year’s intention: use SPSS more, everyday!
December 22nd, 2006
Today, Aleksandar sent us the following question:
“I’m having problems to recode system missing values to 0 with syntax
editor. How can I do that?”
In SPSS Syntax, missing values can be addressed via the keywords “sysmis” or “missing”. For this explanation we assume that in addition to the values 1 and 2, there are also values 3 and 4 which are defined as missing values. Please find some syntax below and an explanation of what they do. var2 stands for the variable name we are recoding.
RECODE var2 (missing = 3).
All missing values (i.e., values 3 and 4 and perhaps also system missing values) will have the value 3. 3 will still be defined as missing.
RECODE var2 (missing = 15).
All missing values (i.e., values 3 and 4 and perhaps also system missing values) will have the value 15. 15 will not be defined as missing.
If you have system missing values and want to recode only these to another value, you can use the keyword “sysmis” instead of “missing”.
RECODE var2 (sysmis = 6).
Again, if you have defined values 3 and 4 as missing, 6 will not be recognized as a (formerly) missing value. You may wish to either define 6 now as missing or to assign a value label that tells you the meaning of 6.
December 7th, 2006
This week we got a question from Mark Mortensen regarding Coding Ordinal Data.
â€œWhat is the best way to set up a variable and code ordinal data when it is generated by a question such as “Rank the following three items using 1 as the most use, 2 the next most use, and three, the least use?”
For this query we can consider the following example.Â In the following data there is three different 4 wheelers brands. The respondent gives the opinion aboutÂ usage on their brand like most often, second most often and least often. It is captured brand wise. Using this syntax easily we can find out which brand is most often, second most often and least often. This recoding we can do vise-versa based on data capturing.
AudiÂ Â Â Â Â BMWÂ Â Â Benz
——- Â ——- ——–
1Â Â Â Â Â Â Â Â Â 2Â Â Â Â Â Â Â Â Â 3
2Â Â Â Â Â Â Â Â Â 3Â Â Â Â Â Â Â Â Â 1
3Â Â Â Â Â Â Â Â Â 1Â Â Â Â Â Â Â Â Â 2
1- Most oftenÂ Â Â Â
2-Second most often
*** The following syntax will recode the respondentâ€™s opinion into new variableÂ rank1, 2 and 3.
IF (Audi =1) Rank1 = 1.
IF (BMW =1) Rank1 = 2.
IF (Benz =1) Rank1 = 3.
IF (Audi =2) Rank2 = 1.
IF (BMW =2) Rank2 = 2.
IF (Benz =2) Rank2 = 3.
IF (Audi =3) Rank3 = 1.
IF (BMW =3) Rank3 = 2.
IF (Benz =3) Rank3 = 3.
Rank1 ‘Most Often’
Rank2 ‘Second Most Often’
Rank3 ‘Least Often’.
Value label Rank1 Rank2 Rank3
After using this syntax we will get the new variablesÂ like in this way,
Rank1 Â Rank2Â Â Rank3
——-Â Â —— Â ——–
AudiÂ Â Â Â Â BMWÂ Â Â Benz
BenzÂ Â Â Â AudiÂ Â Â Â Â BMW
BMWÂ Â Â Â BenzÂ Â Â Â Audi
November 3rd, 2006
Hi SPSSlog users,Â
TheÂ following linkÂ is the simpleÂ example for recoding in SPSS and itâ€™s explaining the purpose also. After reading this content,Â I welcomeÂ more discussion on this. At the end all the SPSS Log users will get more information about recoding in SPSS with more examples. In SPSS we have two different method of recoding (Recode into same variable and Recode into Different variable). We will discuss the features and utilization of these two functions from different applications.Â
November 2nd, 2006
This week Cameron send us the following question:
“I am writing about the stereotypes that people hold in regard to public service employees. Participants are required to rate a private, state, federal and local employee on a number of ratings such as efficiency. It is a 7 point Likert scale.
How do I obtain an overall rating score for each participant for each level of employee?”
Cameron, I assume you have already got your data into SPSS. I also assume you have put each score in a different variable and scored every variable with a figure from 1 to 7. To create an overall rating, you can use the Compute function. You can find this under Transform -> Compute.
(Click image for large view)
- In the field Target Variable, you fill in the name of a (new) variable which should contain the overall rating.
- In the field Numeric Expression you create a formula by typing or clicking the right buttons, like the following:
- In this formula the 4 stands for the number of variables.
- When you are finished, press OK.
In the newly created variable you can now find the overall score. If you have any questions about SPSS, please do not hesitate to contact us.
September 29th, 2006
We got a question from Lucinda, who wants to publish her results, but has a problem with the resolution of the output. She asked us:
“I have made some interactive line graphs that have been submitted to a scientific journal for publication. The journal editor says that the resolution of the graphs is not high enough to print. Do you know how I can increase the resolution of the graphs?”
You can export your graphs into different file formats:
1. Rightclick your chart (in the Output window)
2. Choose Eport, which gives you the following pop-up screen:
3. Set the file type to Postscript (EPS). This is the file format most graphical guys (DTP-ers) can handle this format without a problem. Set the other options according to your wishes, and press OK.
If you have any other questions, please don’t hesitate to contact us.
September 19th, 2006
We received a question from Ilan Shrira, who got an error while saving a file:
I just bought a 120 gigabyte external hard drive, and whenever I try to save an SPSS file
that’s more than 4 gigabyte onto it, it stops and says “Warning #5322, The attempt to save the data file has failed because the disk is full, an I/O error has occurred, the variable dictionary is invalid, or the task was interrupted”
I didn’t have any trouble saving 2 or 3 gigabyte files of the save type. Is is possible that there’s some other kind of glitch in my file.”
To our information there is no limitation in file size, variables or cases. This information is not checked with SPSS, since we do not have a support contract. If anyone else has and is willing to ask SPSS about this, we would be very thankfull. But, the cause isÂ probably an error in the data or variables.
TheÂ error has been discussed in the SPSSX-L mailinglist. In this discussion Raynald Levesque suggests the following cause to the problem:
“If you have string variables, check that the number of characters differs
from the declared length of that variable.
eg if you have a variable declared as format A2 but that variable contains 3
characters. In recent versions of SPSS, more integrity tests are performed
when saving a file and this would cause an error.”
You can check your file by hand or use the automated method Raynald suggest in his second post.
August 23rd, 2006
We get a lot of questions about regression analysis. We have dug into this and decided to write a post about it, so we can help everyone with this.
You do a regression when you assume that a variable is influencing another one, like in the following example: We assume that cars that run on Diesel have higher costs.
To test this assumption, we run a Linear Regression in SPSS. Take the following steps:
- Define your dependent and independent variable. In our example Fuel is the indepent variable and Costs is the dependent one.
- Click Analyze
- Go to Regression and click Linear
- Click “Fuel” into the Independent variable field, and “Costs” into the Dependent variable field.
The output exists of:
1 Model Summary, in which you can find the relation between the variables.
R stands for the correlation and gives us the relation between the dependent and the independent variables. The correlation between Fuel and Costs is ,839.
R Square is the proportion of variance in the dependent variable (Costs) which can be predicted from the independent variable (Fuel). This value indicates that 70% of the variance in costs can be predicted from the variable fuel. The Adjusted R-square tries to give an even better calculation for the whole population.
2 ANOVA, which holds data about the significance of the regressionmodel.
The value under Sig. holds the significance value of the regression. In most cases this should be under 0.05. In our example this is 0.00, better it cannot get!
3 Coefficients, gives information about the first line of regression.
Conclusion would be that this regression analysis is significant and that 70% of the variance in costs can be predicted from the variable fuel.
Please find below the SPSS file we used to create this example. Just one note, the information in the SPSS file is not based on anything. Even more, it’s just random data. Please don’t sue us.
Linear Regression Example Cars
August 21st, 2006