Different subsets to open & analyze

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Different subsets to open & analyze

Arnaldo Ferrari Nasi
Hi List,
I have a similar problem.
This is the situation:
I have a long syntax that makes several analyses.
I have one dataset to analyse.
In this dataset there is a variable "target" that assumes 1 to 10 values.
I have to analyse 10 subsets of the data selected each time for a different
value of the target variable.

I do it "manually".

get file  "c:\data.sav".
select if (target =1).
- run syntax -

get file  "c:\data.sav".
select if (target =2).
- run syntax -

...

get file  "c:\data.sav".
select if (target =10).
- run syntax -


How can I do this automatically?

Thanks a lot,
Arnaldo.
Reply | Threaded
Open this post in threaded view
|

Re: Different subsets to open & analyze

Beadle, ViAnn
Check out the SPLIT FILE command. Does this do what you want?

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Arnaldo Ferrari Nasi
Sent: Sunday, March 04, 2007 5:38 AM
To: [hidden email]
Subject: Different subsets to open & analyze

Hi List,
I have a similar problem.
This is the situation:
I have a long syntax that makes several analyses.
I have one dataset to analyse.
In this dataset there is a variable "target" that assumes 1 to 10 values.
I have to analyse 10 subsets of the data selected each time for a different
value of the target variable.

I do it "manually".

get file  "c:\data.sav".
select if (target =1).
- run syntax -

get file  "c:\data.sav".
select if (target =2).
- run syntax -

...

get file  "c:\data.sav".
select if (target =10).
- run syntax -


How can I do this automatically?

Thanks a lot,
Arnaldo.
Reply | Threaded
Open this post in threaded view
|

Re: Different subsets to open & analyze

Raynald Levesque
Hi

Viann's solution works when the syntax is not too complicated (some commands
do not work when SPLIT FILE is in effect.)

A macro is an easy and general solution that can be used:
Proceed as follows:

*////////////////////.
DEFINE !doAnalysis(vname=!TOKENS(1) /maxVal=!TOKENS(1))
!DO !cnt=1 !TO !maxVal
get file  "c:\data.sav".
select if (!vname = !cnt).
* insert syntax here.
!DOEND
!ENDDEFINE.
*////////////////////.

SET MPRINT=YES /PRINTBACK=YES.
!doAnalysis vname=target  maxVal=10.

****************************.
* Here is a working example.
****************************.

*////////////////////.
DEFINE !doAnalysis(vname=!TOKENS(1) /maxVal=!TOKENS(1))
!DO !cnt=1 !TO !maxVal
GET FILE="c:\Program Files\SPSS\employee data.sav".
SELECT IF (!vname =!cnt).
FREQ VAR=educ.
*as many add'l commands as you need here.
!DOEND
!ENDDEFINE.
*////////////////////.

!doAnalysis vname=jobcat maxVal=3.

Regards,

Raynald Levesque [hidden email]
Website: www.spsstools.net

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Beadle, ViAnn
Sent: March 4, 2007 5:47 PM
To: [hidden email]
Subject: Re: Different subsets to open & analyze

Check out the SPLIT FILE command. Does this do what you want?

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Arnaldo Ferrari Nasi
Sent: Sunday, March 04, 2007 5:38 AM
To: [hidden email]
Subject: Different subsets to open & analyze

Hi List,
I have a similar problem.
This is the situation:
I have a long syntax that makes several analyses.
I have one dataset to analyse.
In this dataset there is a variable "target" that assumes 1 to 10 values.
I have to analyse 10 subsets of the data selected each time for a different
value of the target variable.

I do it "manually".

get file  "c:\data.sav".
select if (target =1).
- run syntax -

get file  "c:\data.sav".
select if (target =2).
- run syntax -

...

get file  "c:\data.sav".
select if (target =10).
- run syntax -


How can I do this automatically?

Thanks a lot,
Arnaldo.