SPSSforum.com is the largest free SPSS help resource worldwide.
On this SPSS forum you are sure to get an answer to your question!
Join the forum and let other SPSS users help you.
Hello, I have a large dataset I want to perform regression on. There are two things I'd like to be able to do:
1) Divide the dataset into smaller datasets and have separate regressions for each of them. I want all the results on the same graph. 2) Instead of having hundreds of points I'd like all of the points with the same x value to be averaged.
Are these things possible? If so can you please tell me how they're done?
Joined: Mon Apr 27, 2009 2:19 am Posts: 278 Location: Melbourne, Australia, University
Hi RobinReborn.
In SPSS>File>New>Syntax and copy the syntax below.
Adapt code to your own variable names.
1. The key changes are to "grpvar" and change values 1 2 3 e.g. to !SplitDataSets 11 12 13/. 2. The key name changes are to "XVar" and "YVar".
/* Created by Analyst Techy 03 Mar 2010
/* 1. Divide the dataset into smaller datasets
/* Splits a dataset up by a grouping variable e.g. grpvar /* for this syntax to work you have to have a numeric variable named grpvar /* The grp values are 1, 2,3 within the variable grpvar /* Assuming a recent version of SPSS /* Open SPSS sav file before running
DEFINE !SplitDataSets (!POS !CHAREND ('/'))
!DO !gv !IN (!1)
!LET !SepSets = !CONCAT('SepDataSet',!gv)
DATASET COPY !SepSets. DATASET ACTIVATE !SepSets. FILTER OFF. USE ALL. SELECT IF (grpvar = !gv). EXECUTE.
!DOEND
!ENDDEFINE.
!SplitDataSets 1 2 3/.
/* 2. Same XVar averaged to YVar /* for this syntax to work you have to have a numeric variable named grpvar /* Assuming a recent version of SPSS /* Open SPSS sav file before running
NOTES: 1. It is not ethical for me to provide complete answers to assignment/work solutions. 2. Any solutions I provide on this forum are free of charge, donations go towards the maintenance of the unaffiliated SPSS forum.
Thanks so much for the help but I am still a bit confused. I haven't ever created SPSS syntax before. When I did what you told me, I got three new windows with no data in them. I did change the appropriate variable to grpvar, when I tried changing
!SplitDataSets 1 2 3/
to
!SplitDataSets 0 4 5 9/ (those being the values corresponding to the four sets of data I want to be separated)
I just got four empty windows. What exactly do I need to change?
Also, I do not need to separate the data into multiple files, I need each data set to be on the same graph with a different regression for it.
Joined: Mon Apr 27, 2009 2:19 am Posts: 278 Location: Melbourne, Australia, University
Hi RobinReborn.
Sorry about the delay, I check my messages when I have a spare moment.
OK the first thing to make sure before running your syntax is to make sure you have the SPSS data SAV file open and active (active is when you see a + plus sign on the minimised file (bottom of the screen toolbar).
Its probably best to change your dataset variable names to what I have in the syntax-so you know it works right. From memory the 2 x separate syntaxes were not intended to be run in order or at the same time. So just highlight /* 1. dito and /* 2. dito on 2 separate occasions.
The fact that you said there were 4 x windows, tells me the syntax is working-I am also assuming there were no error messages in the output window log (please make sure you have noot suppressed your error messages).
The chances are its probably the wrong active file is being run (+ sign), or you have not changed the variable names correctly in the syntax.
Can you please copy and paste my amended syntax into the forum reply, and I see if you have made sufficient changes.
_________________ Analyst Techy
NOTES: 1. It is not ethical for me to provide complete answers to assignment/work solutions. 2. Any solutions I provide on this forum are free of charge, donations go towards the maintenance of the unaffiliated SPSS forum.
Users browsing this forum: No registered users and 1 guest
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum