Programming help

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

Programming help

Manoj Soni

Dear Listers

 

Greetings

 

This is to have help from you guys that I have a spss query mentioned following.

 

I have one spss data set that contains limit of  family members up to 25 members in household organized in  following fashion.

 

 

IDvariables   TotMem    Memno$01      Age$01                    Sex$01                  Education$01       Memno$02       Age$02   Sex$02    Education$02  …           .up to Memno$25

Whatever                                            1                              what ever the data is                                          2                         what ever the data is                                                   25

 

This is one household data and exists in one row and data is filled up to based on TotMem  variable ,suppose Totmem =6 then data is only upto Mem$06 and that will have value 6 and all rest from Memno$07 to Mem$25 will be blank.

 

What is want is, all Members information should come in different rows, because all these variables age,sex,education have the same attributes.

I want in just like below.

 

IDvariable                            MemNo.                              Age                        Sex                         Education                           

IDvariable                            1                              what ever the data is

IDvariable                            2                              what ever the data is

…………………..up to         25

 

I hope u understand my query, still I can give u data file also, if required.

 

I want to do it programmatically , kindly help in this regard.

 

Thanks in advance

 

With best regards

Manoj Kumar Soni

Assistant Data Analyst

Institute of Health Management Research.

1, P.D. Marg, Near Sanganer Airport.

Jaipur. India. 302011

 

Reply | Threaded
Open this post in threaded view
|

Re: Programming help

Maguin, Eugene
Manoj,

Read up on the Varstocases command in the syntax reference. I haven't used
varstocases for a while and I may have some bits wrong. That said, I would
start with this syntax.

Varstocases /make member from Memno$01 Memno$02 Memno$03 ... Memno$25/
   make age from age$01 age$02 age$03 ... age$25/
   make sex from sex$01 sex$02 sex$03 ... sex$25/
   make education from education$01 education$02 education$03 ...
education$25/
   drop=totmem/null=drop.

Two issues for you to decide about are 1) whether to keep or drop totmem and
2) whether you want to create records for nonexistant members. Null=drop is
the default, which will give you as many records per case as there are
members in the group. I have always used varstocases with datasets that are
structured as memno$01 to memno$25, age$01 to age$25. As a result my make
statements are simply, for example, make age=age$01 to age$01.

As I read the documentation, a list of variables should work as well.

Gene Maguin



>>I have one spss data set that contains limit of  family members up to 25
members in household organized in  following fashion.

IDvariables   TotMem Memno$01 Age$01 Sex$01 Education$01  Memno$02  Age$02
Sex$02    Education$02  .           .up to Memno$25
Whatever                                            1
what ever the data is                                          2
what ever the data is                                                   25

This is one household data and exists in one row and data is filled up to
based on TotMem  variable ,suppose Totmem =6 then data is only upto Mem$06
and that will have value 6 and all rest from Memno$07 to Mem$25 will be
blank.
What is want is, all Members information should come in different rows,
because all these variables age,sex,education have the same attributes.

I want in just like below.

IDvariable   MemNo.  Age  Sex  Education
IDvariable       1    what ever the data is
IDvariable       2    what ever the data is
.........up to         25

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Programming help

John F Hall
In reply to this post by Manoj Soni
Gene or one of the other listers will probably solve this long before me, as, even with the manual, I need to think quite hard about it.  Have a look at pages 629ff of the command syntax for handling hierarchical files.  You may be able to produce what you want working from your current SPSS saved file, but you may need to work from your original raw data (or generate a new data set) and read it into SPSS again. 
 
You can find the reference by clicking:
 
Help
Command syntax reference
 
and scrolling down to find
 
file type
file type end.
 
Also we need to know what kind of analysis you want to produce and at what level of (dis)aggregation.
 
----- Original Message -----
Sent: Thursday, February 11, 2010 9:34 AM
Subject: RE: Programming help

Dear Gene Maguin

 

Thanks for your reply.

 

I have applied your solution to my data file and still it is showing an error.

 

This time I have attached actual data file and syntax file for you.

 

I hope for the solution, where am I doing mistake.

 

Thanks in advance

Regards

 

 

Manoj Kumar Soni

Assistant Data Analyst

Institute of Health Management Research.

1, P.D. Marg, Near Sanganer Airport.

Jaipur. India. 302011

 

From: John F Hall [mailto:[hidden email]]
Sent: Wednesday, February 10, 2010 10:49 PM
To: Manoj
Cc: Gene Maguin; Westlake Andrew
Subject: Re: Programming help

 

Its a long time since I did anything like this, but as far as I know SPSS can handle hierarchical data with fixed or varying numbers of trailer records, but I think the data have to be specially arranged first.  I vaguely remember a command

 

file type nested

 

or similar, but that was in 1984 or thereabouts, when we did the user manual for the first British Crime Survey.  Copying this to Andrew Westlake who works on the BCS and may be able to help.

 

Manoj,

Read up on the Varstocases command in the syntax reference. I haven't used
varstocases for a while and I may have some bits wrong. That said, I would
start with this syntax.

Varstocases /make member from Memno$01 Memno$02 Memno$03 ... Memno$25/
   make age from age$01 age$02 age$03 ... age$25/
   make sex from sex$01 sex$02 sex$03 ... sex$25/
   make education from education$01 education$02 education$03 ...
education$25/
   drop=totmem/null=drop.

Two issues for you to decide about are 1) whether to keep or drop totmem and
2) whether you want to create records for nonexistant members. Null=drop is
the default, which will give you as many records per case as there are
members in the group. I have always used varstocases with datasets that are
structured as memno$01 to memno$25, age$01 to age$25. As a result my make
statements are simply, for example, make age=age$01 to age$01.

As I read the documentation, a list of variables should work as well.

Gene Maguin


----- Original Message -----

Sent: Wednesday, February 10, 2010 10:46 AM

Subject: Programming help

 

Dear Listers

 

Greetings

 

This is to have help from you guys that I have a spss query mentioned following.

 

I have one spss data set that contains limit of  family members up to 25 members in household organized in  following fashion.

 

 

IDvariables   TotMem    Memno$01      Age$01                    Sex$01                  Education$01       Memno$02       Age$02   Sex$02    Education$02  …           .up to Memno$25

Whatever                                            1                              what ever the data is                                          2                         what ever the data is                                                   25

 

This is one household data and exists in one row and data is filled up to based on TotMem  variable ,suppose Totmem =6 then data is only upto Mem$06 and that will have value 6 and all rest from Memno$07 to Mem$25 will be blank.

 

What is want is, all Members information should come in different rows, because all these variables age,sex,education have the same attributes.

I want in just like below.

 

IDvariable                            MemNo.                              Age                        Sex                         Education                           

IDvariable                            1                              what ever the data is

IDvariable                            2                              what ever the data is

…………………..up to         25

 

I hope u understand my query, still I can give u data file also, if required.

 

I want to do it programmatically , kindly help in this regard.

 

Thanks in advance

 

With best regards

Manoj Kumar Soni

Assistant Data Analyst

Institute of Health Management Research.

1, P.D. Marg, Near Sanganer Airport.

Jaipur. India. 302011