I have got a data set which contains yearly counts of deliveries of babies. First, there is the total number, and then there are a set of variables counting the number of these deliveries which were of different categories (vaginal, caesarean,...) . In order to present this material in an understandable way (line plots of proportions) and also to calculate for example a (chisquare) trend test, the data must be rearranged in some way. The proportions can naturally be calculated and subsequently described graphically, but not if I want to make a trend test. And there should be some other way than to calculate a whole new set of variables, since there are quite many already for the counts.
First I thought that WEIGHT could be used, but I couldn't make it work as intended. The data could also be expanded using some kind of loop producing a long data set of 0's and 1's, but it seems somewhat complicated for such a simple task. An example of a small part of the data: DATA LIST LIST /year (F4) total (F4) type_A (F4). BEGIN DATA 2013 1617 1442 2012 1807 1584 2011 1903 1676 2010 1920 1676 2009 1832 1586 2008 1906 1659 2007 1701 1456 END DATA. To be more specific, I want to calculate (and plot) the quota between type A and total for each year. And also to do some chisquare calculation of a trend test. This should be simple, shouldn't it? So what do I miss here? Robert ===================== 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
Robert Lundqvist
|
Administrator
|
Does this give what you want? (It's a pretty quick & dirty attempt, and can no doubt be cleaned up).
NEW FILE. DATASET CLOSE all. DATA LIST LIST /year (F4) total (F4) type_A (F4). BEGIN DATA 2013 1617 1442 2012 1807 1584 2011 1903 1676 2010 1920 1676 2009 1832 1586 2008 1906 1659 2007 1701 1456 END DATA. SORT CASES by year. DATASET NAME F1. DATASET COPY F2. ADD FILES file = F1 / IN = A / file = F2 / BY year. EXECUTE. DATASET NAME final. DATASET ACTIVATE final. DATASET CLOSE all. DO IF A. - COMPUTE Kount = type_A. - COMPUTE PercentA = Kount / total. ELSE. - COMPUTE Kount = total - type_A. END IF. FORMATS Kount(f5.0). WEIGHT by Kount. CROSSTABS year by A / cells = count row / stat = chisqr . WEIGHT off. TEMPORARY. SELECT if A. GRAPH /LINE(SIMPLE)=VALUE(PercentA) BY year.
--
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 |