|
Hello there,
I have a question that needs your kindly input. I want to add several variables to muliple SPSS data files. Each added variable will have same value for each case in a single file. Take an example of the following syntax, suppose I need to create a variable "schoolname" in both dataset school1 and school2, and assign a value "firstschool" in dataset school1 and "secondschool" in school2. I've tried to do multiple DEFINE at the same time (or call it nested define?) but SPSS15 seems not to support that. Any suggestions? Thanks! hui define !create (student=!CMDEND). !let !datpath = !unquote("C:\mydata\"). !do !stu !in(!student). !let !indata = !concat('"',!datpath,!stu,'.sav"'). get file = !indata . DESCRIPTIVES VARIABLES=q57 /STATISTICS=MEAN STDDEV MIN MAX . !doend !enddefine !create student= school1 school2 . ===================== 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 |
|
Without going into the details here (macros give me a headache and really
are unnecessary anymore), where are the compute statements to create schoolname within this macro? -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Hui Zhao Sent: Friday, January 30, 2009 12:15 PM To: [hidden email] Subject: adding same variables in multiple files Hello there, I have a question that needs your kindly input. I want to add several variables to muliple SPSS data files. Each added variable will have same value for each case in a single file. Take an example of the following syntax, suppose I need to create a variable "schoolname" in both dataset school1 and school2, and assign a value "firstschool" in dataset school1 and "secondschool" in school2. I've tried to do multiple DEFINE at the same time (or call it nested define?) but SPSS15 seems not to support that. Any suggestions? Thanks! hui define !create (student=!CMDEND). !let !datpath = !unquote("C:\mydata\"). !do !stu !in(!student). !let !indata = !concat('"',!datpath,!stu,'.sav"'). get file = !indata . DESCRIPTIVES VARIABLES=q57 /STATISTICS=MEAN STDDEV MIN MAX . !doend !enddefine !create student= school1 school2 . ===================== 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 |
|
sorry about the confusion. I will try to explain more here. Suppose I
have two datasets saved on the same folder: C:\mydata\school1 C:\mydata\school2 What I need to do is to add an additional string variable "schoolname" in each file. And the data will look like: In file C:\mydata\school1 schoolname firstschool firstschool firstschool ... In file C:\mydata\school2 schoolname secondschool secondschool secondschool ... Is there anyway to automate the whole process, because I have about 50 files to deal with? Thanks a lot! hui On Fri, Jan 30, 2009 at 2:49 PM, ViAnn Beadle <[hidden email]> wrote: > Without going into the details here (macros give me a headache and really > are unnecessary anymore), where are the compute statements to create > schoolname within this macro? > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Hui > Zhao > Sent: Friday, January 30, 2009 12:15 PM > To: [hidden email] > Subject: adding same variables in multiple files > > Hello there, > > I have a question that needs your kindly input. I want to add several > variables to muliple SPSS data files. Each added variable will have > same value for each case in a single file. Take an example of the > following syntax, suppose I need to create a variable "schoolname" in > both dataset school1 and school2, and assign a value "firstschool" in > dataset school1 and "secondschool" in school2. I've tried to do > multiple DEFINE at the same time (or call it nested define?) but > SPSS15 seems not to support that. > Any suggestions? Thanks! > > hui > > define !create (student=!CMDEND). > > !let !datpath = !unquote("C:\mydata\"). > > !do !stu !in(!student). > > !let !indata = !concat('"',!datpath,!stu,'.sav"'). > > get file = !indata . > > DESCRIPTIVES > VARIABLES=q57 > /STATISTICS=MEAN STDDEV MIN MAX . > > !doend > !enddefine > !create student= school1 school2 . > > ===================== > 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 > > -- Hui Zhao, Ph.D. Research & Evaluation Specialist I Edvantia, Inc. 304.347.0411 (work) 360.232.3794 (cell) ===================== 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 ViAnn Beadle
sorry about the confusion. I will try to explain more here. Suppose I
have two datasets saved on the same folder: C:\mydata\school1.sav C:\mydata\school2.sav What I need to do is to add an additional string variable "schoolname" in each file. And the data will look like: In file C:\mydata\school1.sav schoolname firstschool firstschool firstschool ... In file C:\mydata\school2.sav schoolname secondschool secondschool secondschool ... Is there anyway to automate the whole process, because I have about 50 files to deal with? Thanks a lot! hui On Fri, Jan 30, 2009 at 2:49 PM, ViAnn Beadle <[hidden email]> wrote: > Without going into the details here (macros give me a headache and really > are unnecessary anymore), where are the compute statements to create > schoolname within this macro? > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Hui > Zhao > Sent: Friday, January 30, 2009 12:15 PM > To: [hidden email] > Subject: adding same variables in multiple files > > Hello there, > > I have a question that needs your kindly input. I want to add several > variables to muliple SPSS data files. Each added variable will have > same value for each case in a single file. Take an example of the > following syntax, suppose I need to create a variable "schoolname" in > both dataset school1 and school2, and assign a value "firstschool" in > dataset school1 and "secondschool" in school2. I've tried to do > multiple DEFINE at the same time (or call it nested define?) but > SPSS15 seems not to support that. > Any suggestions? Thanks! > > hui > > define !create (student=!CMDEND). > > !let !datpath = !unquote("C:\mydata\"). > > !do !stu !in(!student). > > !let !indata = !concat('"',!datpath,!stu,'.sav"'). > > get file = !indata . > > DESCRIPTIVES > VARIABLES=q57 > /STATISTICS=MEAN STDDEV MIN MAX . > > !doend > !enddefine > !create student= school1 school2 . > > ===================== > 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 > > -- Hui Zhao, Ph.D. Research & Evaluation Specialist I Edvantia, Inc. 304.347.0411 (work) 360.232.3794 (cell) ===================== 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 |
