|
Hi SPSS Listserve,
I have a sintaxis that run every month to diferents datasets whit some diferences beetwen them and a lot of variables. For example one line is: ....... COMPUTE d1 = SUM(d11, d12, d13, d14) ....... The problem is that if in one month the variable d11 is missing the process dosen´t work. Are there any way to solve this without change de sintaxis?? Thanks!!! Angelina |
|
Hallo again, my question was no good. My problem is that in some datasets the variable dosen´t exist, for example in month1, the variables are: id, a1, a2, a3, d11, d12, d13, d14.. and in month2: id, a1, a2, a3, d12, d13....(no d11).
Thanks again!!! Angelina ---------- Forwarded message ---------- From: angelina garnica <[hidden email]> Date: Thu, Aug 27, 2009 at 10:10 AM Subject: SUM Variables To: [hidden email] Hi SPSS Listserve, I have a sintaxis that run every month to diferents datasets whit some diferences beetwen them and a lot of variables. For example one line is: ....... COMPUTE d1 = SUM(d11, d12, d13, d14) ....... The problem is that if in one month the variable d11 is missing the process dosen´t work. Are there any way to solve this without change de sintaxis?? Thanks!!! Angelina |
|
In reply to this post by angelina garnica
If zero is a legitimate assumption of the value for the missing variables then COMPUTE d1 = SUM.1(d11, d12, d13, d14). Art Kendall Social Research Consultants angelina garnica wrote: Hi SPSS Listserve,===================== 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
Art Kendall
Social Research Consultants |
|
Art,
I thought of what you wrote in your reply but I think the situation depends completely on the the meaning of 'missing'. If Angelina means that all variables involved in the sum are present in every month's dataset and that in different months different variables have a value of missing (sysmis or user-defined), then I completely agree with you. But, as I read her first posting, it sounded like she was saying that in different months, different variables are not contained in the month's dataset. Thus, the sum function would yield an error. Angelina, would you define what you mean by 'missing'? 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 |
|
I´m sorry, my first question was no good. The problem is that in some
datasets the variable dosen´t exist, for example in month1, the
variables are: id, a1, a2, a3, d11, d12, d13, d14.. and in month2: id,
a1, a2, a3, d12, d13....(no d11).
thanks again!! Angelina On Thu, Aug 27, 2009 at 11:16 AM, Gene Maguin <[hidden email]> wrote: Art, |
|
Hello Angelica,
So the dataset is different each month? I would do it in the following way: make a dataset without cases but containing all variables that can exist. Open this dataset and merge the monthly dataset with the empty dataset. Now all variables exist (but with missing variables) and you can use sum(a1,a2...). Frans Date: Thu, 27 Aug 2009 11:28:44 -0300 From: [hidden email] Subject: Re: SUM Variables To: [hidden email] I´m sorry, my first question was no good. The problem is that in some datasets the variable dosen´t exist, for example in month1, the variables are: id, a1, a2, a3, d11, d12, d13, d14.. and in month2: id, a1, a2, a3, d12, d13....(no d11). thanks again!! Angelina On Thu, Aug 27, 2009 at 11:16 AM, Gene Maguin <[hidden email]> wrote: Art, Deel je favoriete foto's online met Windows Live Photos |
|
In reply to this post by angelina garnica
Angelina,
Ok, that's what I thought you meant. My first thought was a macro (see the syntax reference for an explanation of macros) but I don't think there'd be any gain. My second thought was something involving either python or a script. I'm guessing that something could be written in which the list of every variable that could be used in your sum is predefined and that list is compared against the variable list for the current (target) dataset to identify common variables and the sum function constructed from the intersection of two variable lists. However, other people on the list know far more about both scripts and python than I do, which is nothing--except for what I've seen posted. 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 |
|
In reply to this post by Maguin, Eugene
Art, that is the problem, some variables do not exist in some data sets,
There is no problem in assume they had zero or missing values, because then I work whit the sum of them, for exaple d1 = d11 + d12 + d13, so if in one month d13 is 0 it dosen´t matter. Some of the variables are consecutive, so i can use TO, but Tim and Gene suggest me to create an unique structure with all posibles variables and them add the data of ech month, using the SUM comand.
On Thu, Aug 27, 2009 at 12:04 PM, Art Kendall <[hidden email]> wrote: Gene |
|
In reply to this post by Frans Marcelissen-3
You can use the APPLY DICTIONARY command with the NEWVARS switch to do something similar, but you still need a source dataset that contains all possible vars. The donor dataset needs to be only N = 1, but the string widths need to be the same for equivalent string vars across datasets.
Cheers!! Albert-Jan --- On Thu, 8/27/09, Frans Marcelissen <[hidden email]> wrote: > From: Frans Marcelissen <[hidden email]> > Subject: Re: [SPSSX-L] SUM Variables > To: [hidden email] > Date: Thursday, August 27, 2009, 4:44 PM > > > > #yiv1302602289 .hmmessage P > { > margin:0px;padding:0px;} > #yiv1302602289 { > font-size:10pt;font-family:Verdana;} > > > > Hello Angelica, > > So the dataset is different each month? I would > do it in the following way: make a dataset without > cases but containing all variables that can exist. Open this > dataset and merge the monthly dataset with the empty > dataset. Now all variables exist > (but with missing variables) and you can use > sum(a1,a2...). > > Frans > > > > Date: Thu, 27 Aug 2009 11:28:44 -0300 > From: [hidden email] > Subject: Re: SUM Variables > To: [hidden email] > > I´m sorry, my first question was no good. The problem is > that in some datasets the variable dosen´t exist, for > example in month1, the variables are: id, a1, a2, a3, d11, > d12, d13, d14.. and in month2: id, a1, a2, a3, d12, > d13....(no d11). > > thanks again!! > Angelina > > > > On Thu, Aug 27, 2009 at 11:16 > AM, Gene Maguin <[hidden email]> > wrote: > > Art, > > I thought of what you wrote in your reply but I think the > situation depends > completely on the the meaning of 'missing'. If > Angelina means that all > variables involved in the sum are present in every > month's dataset and that > in different months different variables have a value of > missing (sysmis or > user-defined), then I completely agree with you. But, as I > read her first > posting, it sounded like she was saying that in different > months, different > variables are not contained in the month's dataset. > Thus, the sum function > would yield an error. > > Angelina, would you define what you mean by > 'missing'? > > 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 > > > Deel je favoriete foto's online met Windows > Live Photos > ===================== 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 |
|
Administrator
|
In reply to this post by angelina garnica
OK, so for months that have d11, you want: COMPUTE d1 = SUM(d11, d12, d13, d14). But what do you want for months that do not have d11? And how do you know whether the file you're using has d11 or not? E.g., is there a d11 flag variable that = 1 if d11 exists in the file and 0 otherwise? If not, could you add such a variable? With such an indicator, you could do:\ do if d11flag. - COMPUTE d1 = SUM(d11, d12, d13, d14). else. - COMPUTE d1 = SUM(d12, d13, d14). end if. exe. Alternatively, if you know which months have d11, and if there is a MONTH variable in each file, you could do something like: do if any(month,1,4,7,9,12). - COMPUTE d1 = SUM(d11, d12, d13, d14). else. - COMPUTE d1 = SUM(d12, d13, d14). end if. exe. You would have to replace my 1,4,7,9,12 with the months that have d11, of course.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
| Free forum by Nabble | Edit this page |
