|
Hi All!
Does anyone know of a way to count or report on the total number of cases in a datafile, and then use that number in syntax? My example; I have a large set of data that is to be broken into a number of smaller subsets, each of varying size. For each subset of data I want to run a QUICK CLUSTER. But I want to vary the target number of clusters in proportion to the size of the data subset. If I could use the total number of cases as a variable in syntax I could do this! Any suggestions gratefully received. Mark ====================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 |
|
The easiest way to do this is with programmability. For example, the code below creates an SPSS macro named !Ngrp as the case count / 100. Then !Ngrp can be used in regular syntax.
Note that sometimes SPSS does not know the case count if the data have not already been passed once and the data source is not an SPSS sav file. begin program. import spss, spssaux casecount = spssaux.getShow("N") numgroups = casecount/100 spss.SetMacroValue('!Ngrp', str(numgroups)) end program. HTH, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mark Lenel Sent: Wednesday, February 13, 2008 11:30 AM To: [hidden email] Subject: [SPSSX-L] Using a case count in syntax Hi All! Does anyone know of a way to count or report on the total number of cases in a datafile, and then use that number in syntax? My example; I have a large set of data that is to be broken into a number of smaller subsets, each of varying size. For each subset of data I want to run a QUICK CLUSTER. But I want to vary the target number of clusters in proportion to the size of the data subset. If I could use the total number of cases as a variable in syntax I could do this! Any suggestions gratefully received. Mark ======= 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 ===================== 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 |
|
In reply to this post by Mark Lenel
Jon,
Many thanks for your input. It has forced me over the edge into the murky (but potentially fantastic) world of programmability. After a false start - and realising I needed to install Python and the SPSS programmability interface to make anything work (doh!) - it was up and running. I actually found a more direct measure of the number of cases, using the spss.GetCaseCount function. BEGIN PROGRAM. import spss casecount=spss.GetCaseCount() numgroups = casecount/100 spss.SetMacroValue('!Ngrp', str(numgroups)) END PROGRAM. Thanks again, Mark -----Original Message----- From: Peck, Jon [mailto:[hidden email]] Sent: 13 February 2008 20:56 To: Mark Lenel; [hidden email] Subject: RE: [SPSSX-L] Using a case count in syntax The easiest way to do this is with programmability. For example, the code below creates an SPSS macro named !Ngrp as the case count / 100. Then !Ngrp can be used in regular syntax. Note that sometimes SPSS does not know the case count if the data have not already been passed once and the data source is not an SPSS sav file. begin program. import spss, spssaux casecount = spssaux.getShow("N") numgroups = casecount/100 spss.SetMacroValue('!Ngrp', str(numgroups)) end program. HTH, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mark Lenel Sent: Wednesday, February 13, 2008 11:30 AM To: [hidden email] Subject: [SPSSX-L] Using a case count in syntax Hi All! Does anyone know of a way to count or report on the total number of cases in a datafile, and then use that number in syntax? My example; I have a large set of data that is to be broken into a number of smaller subsets, each of varying size. For each subset of data I want to run a QUICK CLUSTER. But I want to vary the target number of clusters in proportion to the size of the data subset. If I could use the total number of cases as a variable in syntax I could do this! Any suggestions gratefully received. Mark ======= 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 ===================== 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 |
|
In reply to this post by Peck, Jon
Hi all,
Just a quick question about Jon's programmability suggestion. Why use: casecount = spssaux.getShow("N") and not: casecount = spss.GetCaseCount() Cheers!! Albert-Jan --- "Peck, Jon" <[hidden email]> wrote: > The easiest way to do this is with programmability. > For example, the code below creates an SPSS macro > named !Ngrp as the case count / 100. Then !Ngrp can > be used in regular syntax. > > Note that sometimes SPSS does not know the case > count if the data have not already been passed once > and the data source is not an SPSS sav file. > > begin program. > import spss, spssaux > casecount = spssaux.getShow("N") > numgroups = casecount/100 > spss.SetMacroValue('!Ngrp', str(numgroups)) > end program. > > HTH, > Jon Peck > > -----Original Message----- > From: SPSSX(r) Discussion > [mailto:[hidden email]] On Behalf Of Mark > Lenel > Sent: Wednesday, February 13, 2008 11:30 AM > To: [hidden email] > Subject: [SPSSX-L] Using a case count in syntax > > Hi All! > > > > Does anyone know of a way to count or report on the > total number of > cases in a datafile, and then use that number in > syntax? > > > > My example; I have a large set of data that is to be > broken into a > number of smaller subsets, each of varying size. > For each subset of > data I want to run a QUICK CLUSTER. But I want to > vary the target > number of clusters in proportion to the size of the > data subset. If I > could use the total number of cases as a variable in > syntax I could do > this! > > > > Any suggestions gratefully received. > > > > Mark > > ======= > 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 > > ===================== > 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 > ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ ===================== 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 |
|
Either one would work. getShow is more general in being able to retrieve any items that can be specified with SHOW item. The case count is just one of many such things.
-----Original Message----- From: Albert-jan Roskam [mailto:[hidden email]] Sent: Thursday, February 14, 2008 3:36 AM To: Peck, Jon; [hidden email] Subject: Re: Using a case count in syntax Hi all, Just a quick question about Jon's programmability suggestion. Why use: casecount = spssaux.getShow("N") and not: casecount = spss.GetCaseCount() Cheers!! Albert-Jan --- "Peck, Jon" <[hidden email]> wrote: > The easiest way to do this is with programmability. > For example, the code below creates an SPSS macro > named !Ngrp as the case count / 100. Then !Ngrp can > be used in regular syntax. > > Note that sometimes SPSS does not know the case > count if the data have not already been passed once > and the data source is not an SPSS sav file. > > begin program. > import spss, spssaux > casecount = spssaux.getShow("N") > numgroups = casecount/100 > spss.SetMacroValue('!Ngrp', str(numgroups)) > end program. > > HTH, > Jon Peck > > -----Original Message----- > From: SPSSX(r) Discussion > [mailto:[hidden email]] On Behalf Of Mark > Lenel > Sent: Wednesday, February 13, 2008 11:30 AM > To: [hidden email] > Subject: [SPSSX-L] Using a case count in syntax > > Hi All! > > > > Does anyone know of a way to count or report on the > total number of > cases in a datafile, and then use that number in > syntax? > > > > My example; I have a large set of data that is to be > broken into a > number of smaller subsets, each of varying size. > For each subset of > data I want to run a QUICK CLUSTER. But I want to > vary the target > number of clusters in proportion to the size of the > data subset. If I > could use the total number of cases as a variable in > syntax I could do > this! > > > > Any suggestions gratefully received. > > > > Mark > > ======= > 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 > > ===================== > 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 > ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ ===================== 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 |
|
hi all,
I have a question regarding how to set up my data. I have a large dataset and for each respondent information about his parents (if still alive) and about his children (if he has any). till now I have analyzed each direction seperately using dyads. so each respodent has 1 line for each child (for each parent). I want to go a step further and analyze the relation to parents and children at the same time. In order to do so I need triads. is it possible to just merge the two dyads-datasets? or is there a better way? thanks, christian ===================== 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 |
|
Christian,
I think that a few other people have more experience with this sort of dataset than I do (which is none) because a couple of questions like this have been posted before. That said, >>I have a large dataset and for each respondent information about his parents (if still alive) and about his children (if he has any). till now I have analyzed each direction seperately using dyads. so each respodent has 1 line for each child (for each parent). I want to go a step further and analyze the relation to parents and children at the same time. In order to do so I need triads. is it possible to just merge the two dyads-datasets? or is there a better way? It sounds like that in your current dataset you have respondents who may have children and who may have parents. So three generations are possible. I think it would help if you were to describe the structure of the dataset and how you identify how records go together. Please describe 1) how you know which records are children of a given respondent and 2) how you would know which records are the grandchildren of a respondent's parent? Gene Maguin ===================== 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 |
|
dear gene,
thanks a lot for your answer. I was indeed a little bit unclear. below you find an example of waht i want to do, but I'm unsure if the last step is correct. In my dataset each child has a variable, and also each parent. I'm using varstocases to build a dataset where each child (parent) now has a line for each respondent. for triads I assume I can just use varstoces two times in a row (one time for children and one time for parents). am I correct? christian ************************************************************** *example. ************************************************************** *dyads for children. data list list /persid (F2.0) hhid (F2.0) gender (F2.0) age (F2.0) genderch1 (F2.0) genderch2 (F2.0) genderch3 (F2.0) genderch4 (F2.0) genderch5 (F2.0) genderpar1 (F2.0) genderpar2 (F2.0). BEGIN DATA 1 1 1 50 1 1 2 1 1 1 2 2 1 2 60 1 2 2 1 2 9 9 3 2 1 74 2 2 2 1 1 1 2 4 2 2 65 1 2 2 2 2 9 9 5 3 1 50 2 1 2 2 1 1 2 6 4 1 51 2 1 2 2 2 1 2 7 4 2 55 1 1 2 1 1 9 9 8 5 2 80 2 1 2 2 2 1 2 END DATA. LIST. varstocases /make genkid from genderch1 to genderch5 /index dyad_kid. **************************** ***dyads for parents. data list list /persid (F2.0) hhid (F2.0) gender (F2.0) age (F2.0) genderch1 (F2.0) genderch2 (F2.0) genderch3 (F2.0) genderch4 (F2.0) genderch5 (F2.0) genderpar1 (F2.0) genderpar2 (F2.0). BEGIN DATA 1 1 1 50 1 1 2 1 1 1 2 2 1 2 60 1 2 2 1 2 9 9 3 2 1 74 2 2 2 1 1 1 2 4 2 2 65 1 2 2 2 2 9 9 5 3 1 50 2 1 2 2 1 1 2 6 4 1 51 2 1 2 2 2 1 2 7 4 2 55 1 1 2 1 1 9 9 8 5 2 80 2 1 2 2 2 1 2 END DATA. LIST. varstocases /make genpar from genderpar1 to genderpar2 /index dyad_par. **************************** *triads?. data list list /persid (F2.0) hhid (F2.0) gender (F2.0) age (F2.0) genderch1 (F2.0) genderch2 (F2.0) genderch3 (F2.0) genderch4 (F2.0) genderch5 (F2.0) genderpar1 (F2.0) genderpar2 (F2.0). BEGIN DATA 1 1 1 50 1 1 2 1 1 1 2 2 1 2 60 1 2 2 1 2 9 9 3 2 1 74 2 2 2 1 1 1 2 4 2 2 65 1 2 2 2 2 9 9 5 3 1 50 2 1 2 2 1 1 2 6 4 1 51 2 1 2 2 2 1 2 7 4 2 55 1 1 2 1 1 9 9 8 5 2 80 2 1 2 2 2 1 2 END DATA. LIST. varstocases /make genkid from genderch1 to genderch5 /index dyad_kid. varstocases /make genpar from genderpar1 to genderpar2 /index dyad_par. sort cases by persid hhid dyad_kid dyad_par. Gene Maguin schrieb: > Christian, > > I think that a few other people have more experience with this sort of > dataset than I do (which is none) because a couple of questions like this > have been posted before. That said, > >>> I have a large dataset and for each respondent information about his > parents (if still alive) and about his children (if he has any). > till now I have analyzed each direction seperately using dyads. > so each respodent has 1 line for each child (for each parent). > > I want to go a step further and analyze the relation to parents and > children at the same time. > > In order to do so I need triads. > > is it possible to just merge the two dyads-datasets? > or is there a better way? > > It sounds like that in your current dataset you have respondents who may > have children and who may have parents. So three generations are possible. I > think it would help if you were to describe the structure of the dataset and > how you identify how records go together. Please describe 1) how you know > which records are children of a given respondent and 2) how you would know > which records are the grandchildren of a respondent's parent? > > Gene Maguin > > ===================== > 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 > ===================== 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 |
| Free forum by Nabble | Edit this page |
