![]() replace the active dataset with the results. In the AGGREGATE command, the “ *” means “this file” i.e. the value of item is used as the subscript index into the vector vec.īelow the data of the first 2 respondents before the AGGREGATE command … respID.As long as no procedure executes, these variables remain accessible as vec( subscript ) We will use the VECTOR command once again, but this time to create new variables. We will use the file reshaped.sav we created in the previous section (I added the respID variable because we will need it here). This happens often with time series data. Sometimes, instead, you want to join observations into a single record. I used reshape2.sav to do the correspondence analysis in R (package ca): + XSAVE OUTFILE = "reshaped2.sav" /KEEP = member item. VALUE LABELS item 1 "independence" 2 "friends" 3 "family"Ĥ "culture" 5 "entertainment" 6 "religion" 7 "politics".Ī correspondence analysis (not yet available in PSPP) would like a format of member item we might write such a record only if the item’s importance rating is high (5, or 4 OR 5): GET FILE = "survey,sav". + XSAVE OUTFILE = "reshaped.sav" /KEEP = respID member item Here is how we create the 7 member item rating records: GET FILE = "survey.sav".ĬOMPUTE respID = $CASENUM /+ Not relevant (need this later) */. While SAVE is a procedure, XSAVE is a transformation. The key to creating multiple records from a single record is the XSAVE command. A format of member item rating, in this case 7 records per respondent, would be preferable for data visualization software that lets the user select the item to view. Sometimes this typical format of many observations per record is not the most suited for your purpose. Here are the first 2 records before the procedure: member KEEP = member politics religion culture ALL.įILE = * means: “operate on this file”, and the keyword ALL means: all the other variables. A neat little trick is the use of this transformation on just one file to reorder the variables in your data set: MATCH FILES FILE = * The MATCH FILES command is used for combining files “horizontally” i.e. VALUE LABELS member 1 "member" 2 "not a member" 3 "ex member". DATA LIST LIST /member independence friends family culture The first column indicates whether the respondent is a member (1), not a member (2), or an ex-member (3) the next 7 columns are his/her importance ratings on a scale of 1 (not at all important) to 5 (extremely important). The syntax below creates a data set with (fictitious) survey data. The SELECT IF transformation marks the current record for deletion if not selected the next procedure (like EXECUTE, or another SORT CASES BY) will physically eliminate the records marked for deletion from the dataset. You can now get rid of these duplicates: SELECT IF NOT isDuplicate. The function LAG( var) returns the value of var in the previous record. ![]() The following syntax sets the variable isDuplicate to true for the second and subsequent records sharing the same key: SORT CASES BY vatNumber.ĬOMPUTE isDuplicate = $CASENUM GT 1 AND vatNumber EQ ![]() In this page you will find some operations I perform fairly often and for which no fast one-click solutions exists. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |