|
Hi,
I'm trying to set up a macro which produces frequency tables on various filters and then exports each table to individual excel files. The macro syntax below works fine but I need to tweak it a little so I can define a file name for each export. This is my first attempt in writing a macro, I'm still unclear exactly what tokens/charend/enclose & cmdend all mean and how to use them. Here is the syntax: DEFINE !seg (xy=!tokens(1)). OUTPUT NEW. USE ALL. COMPUTE filter_$=!CONCAT("(",!xy,"=1)"). FILTER BY filter_$. EXECUTE . FREQ V1. USE ALL. FILTER OFF. SCRIPT "C:\Program Files\SPSS\Scripts\Export_to_Excel_(BIFF).SBS" /("C:\temp\First file output.xls"). /*http://support.spss.com/Tech/default.asp*/. !ENDDEFINE. SET PRINTBACK=ON /MPRINT=ON. !seg xy= filter1. !seg xy=filter2. !seg xy=fillter3. SET MPRINT= OFF. ===================== 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've made some progress after reading the Command Syntax Reference.
Currently my setup uses positional arguments and therefore I can only define a one-word file name for the second positional argument. I need a helping hand so that the macro can facilitate file names of multiple words. DEFINE !seg (!POSITIONAL !tokens(1) /!POSITIONAL !tokens (1)). OUTPUT CLOSE ALL. OUTPUT NEW. USE ALL. COMPUTE filter_$=!CONCAT("(",!1,"=1)"). FILTER BY filter_$. EXECUTE . FREQ V1. USE ALL. FILTER OFF. SCRIPT "C:\Program Files\SPSS\Scripts\Export_to_Excel_(BIFF).SBS" /!CONCAT("('C:\temp\",!2,".xls')"). !ENDDEFINE. SET PRINTBACK=ON /MPRINT=ON. !seg filter1 test. !seg filter2 male !seg filter3 female SET MPRINT= OFF. 2008/8/6 J Sutar <[hidden email]> > Hi, > > I'm trying to set up a macro which produces frequency tables on various > filters and then exports each table to individual excel files. > > The macro syntax below works fine but I need to tweak it a little so I can > define a file name for each export. > > This is my first attempt in writing a macro, I'm still unclear exactly what > tokens/charend/enclose & cmdend all mean and how to use them. > > Here is the syntax: > > DEFINE !seg (xy=!tokens(1)). > > OUTPUT NEW. > > USE ALL. > COMPUTE filter_$=!CONCAT("(",!xy,"=1)"). > FILTER BY filter_$. > EXECUTE . > > FREQ V1. > > USE ALL. > FILTER OFF. > > SCRIPT "C:\Program Files\SPSS\Scripts\Export_to_Excel_(BIFF).SBS" > /("C:\temp\First file output.xls"). > /*http://support.spss.com/Tech/default.asp*/. > > !ENDDEFINE. > > SET PRINTBACK=ON /MPRINT=ON. > !seg xy= filter1. > !seg xy=filter2. > !seg xy=fillter3. > SET MPRINT= OFF. > ===================== 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,
I'd really use AGGREGATE and SAVE TRANSLATE for this. Don't you run into asynchronicity problems with syntax/script? DEFINE !seg (!POSITIONAL !charend('/') /!POSITIONAL !cmdend). [...] !seg filter1 / test file. might work.. Cheers!! Albert-Jan --- On Wed, 8/6/08, J Sutar <[hidden email]> wrote: > From: J Sutar <[hidden email]> > Subject: Re: Using Macro to define file names > To: [hidden email] > Date: Wednesday, August 6, 2008, 7:26 PM > I've made some progress after reading the Command Syntax > Reference. > Currently my setup uses positional arguments and therefore > I can only define > a one-word file name for the second positional argument. I > need a helping > hand so that the macro can facilitate file names of > multiple words. > > > DEFINE !seg (!POSITIONAL !tokens(1) /!POSITIONAL !tokens > (1)). > > OUTPUT CLOSE ALL. > OUTPUT NEW. > > USE ALL. > COMPUTE filter_$=!CONCAT("(",!1,"=1)"). > FILTER BY filter_$. > EXECUTE . > > FREQ V1. > > USE ALL. > FILTER OFF. > > > SCRIPT "C:\Program > Files\SPSS\Scripts\Export_to_Excel_(BIFF).SBS" > /!CONCAT("('C:\temp\",!2,".xls')"). > > !ENDDEFINE. > > SET PRINTBACK=ON /MPRINT=ON. > !seg filter1 test. > !seg filter2 male > !seg filter3 female > SET MPRINT= OFF. > > 2008/8/6 J Sutar <[hidden email]> > > > Hi, > > > > I'm trying to set up a macro which produces > frequency tables on various > > filters and then exports each table to individual > excel files. > > > > The macro syntax below works fine but I need to tweak > it a little so I can > > define a file name for each export. > > > > This is my first attempt in writing a macro, I'm > still unclear exactly what > > tokens/charend/enclose & cmdend all mean and how > to use them. > > > > Here is the syntax: > > > > DEFINE !seg (xy=!tokens(1)). > > > > OUTPUT NEW. > > > > USE ALL. > > COMPUTE > filter_$=!CONCAT("(",!xy,"=1)"). > > FILTER BY filter_$. > > EXECUTE . > > > > FREQ V1. > > > > USE ALL. > > FILTER OFF. > > > > SCRIPT "C:\Program > Files\SPSS\Scripts\Export_to_Excel_(BIFF).SBS" > > /("C:\temp\First file output.xls"). > > /*http://support.spss.com/Tech/default.asp*/. > > > > !ENDDEFINE. > > > > SET PRINTBACK=ON /MPRINT=ON. > > !seg xy= filter1. > > !seg xy=filter2. > > !seg xy=fillter3. > > SET MPRINT= OFF. > > > > ===================== > 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 |
|
Hello listers,
I'm trying to figure out what the best type of analysis is for this data. The data are individuals that at some point in the past have been enrolled in a medical case management program. A nurse keeps in touch with them to try and improve their chronic health condition. The outcome measures I'm looking at are things like lower emergency usage, because their disease is under control, and more visits to their primary care physician, because that's what they need to do to stay healthy. I thought that an interrupted time series analysis made sense here. That way I could compare the slope of say, the number of ER visits, pre and post entry into the case management program. So, after pouring over what I could on the topic, though not going so far as to get a hold of the Box and Jenkins book on the topic, I'm not sure if this is the type of analysis I want. This type of analysis seems to assume that everyone gets the intervention at the same time. Maybe I'm mistaken about this. Let me know. These patients are enrolled in case management at different times. I've thought of just ignoring 'real time' and just standardizing time so that there is pre case management time, and post case management time. I may try this but on the face it it seems like this would open the door for history and selection issues in the least. I've also thought about multilevel modeling. This seems attractive just to deal with the fact that different patients see different doctors, go to different hospitals etc. But can I compare pre and post slopes as I would like with MLM? As always, any help would be much appreciated. Thanks, Matt Matthew Pirritano, Ph.D. Research Analyst IV Orange County Health Care Agency (714) 834-6011 ===================== 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 Albert-Jan Roskam
I agree. AGGREGATE followed by SAVE TRANSLATE would be a better solution.
How do I use AGGREGATE to get the percentage of cases? (I've only started using AGGREGATE command this week). By the way you're solution for the macro worked just fine, thanks. Jignesh 2008/8/6 Albert-jan Roskam <[hidden email]> > Hi, > > I'd really use AGGREGATE and SAVE TRANSLATE for this. Don't you run into > asynchronicity problems with syntax/script? > > DEFINE !seg (!POSITIONAL !charend('/') /!POSITIONAL !cmdend). > > [...] > !seg filter1 / test file. > > might work.. > > Cheers!! > Albert-Jan > > --- On Wed, 8/6/08, J Sutar <[hidden email]> wrote: > > > From: J Sutar <[hidden email]> > > Subject: Re: Using Macro to define file names > > To: [hidden email] > > Date: Wednesday, August 6, 2008, 7:26 PM > > I've made some progress after reading the Command Syntax > > Reference. > > Currently my setup uses positional arguments and therefore > > I can only define > > a one-word file name for the second positional argument. I > > need a helping > > hand so that the macro can facilitate file names of > > multiple words. > > > > > > DEFINE !seg (!POSITIONAL !tokens(1) /!POSITIONAL !tokens > > (1)). > > > > OUTPUT CLOSE ALL. > > OUTPUT NEW. > > > > USE ALL. > > COMPUTE filter_$=!CONCAT("(",!1,"=1)"). > > FILTER BY filter_$. > > EXECUTE . > > > > FREQ V1. > > > > USE ALL. > > FILTER OFF. > > > > > > SCRIPT "C:\Program > > Files\SPSS\Scripts\Export_to_Excel_(BIFF).SBS" > > /!CONCAT("('C:\temp\",!2,".xls')"). > > > > !ENDDEFINE. > > > > SET PRINTBACK=ON /MPRINT=ON. > > !seg filter1 test. > > !seg filter2 male > > !seg filter3 female > > SET MPRINT= OFF. > > > > 2008/8/6 J Sutar <[hidden email]> > > > > > Hi, > > > > > > I'm trying to set up a macro which produces > > frequency tables on various > > > filters and then exports each table to individual > > excel files. > > > > > > The macro syntax below works fine but I need to tweak > > it a little so I can > > > define a file name for each export. > > > > > > This is my first attempt in writing a macro, I'm > > still unclear exactly what > > > tokens/charend/enclose & cmdend all mean and how > > to use them. > > > > > > Here is the syntax: > > > > > > DEFINE !seg (xy=!tokens(1)). > > > > > > OUTPUT NEW. > > > > > > USE ALL. > > > COMPUTE > > filter_$=!CONCAT("(",!xy,"=1)"). > > > FILTER BY filter_$. > > > EXECUTE . > > > > > > FREQ V1. > > > > > > USE ALL. > > > FILTER OFF. > > > > > > SCRIPT "C:\Program > > Files\SPSS\Scripts\Export_to_Excel_(BIFF).SBS" > > > /("C:\temp\First file output.xls"). > > > /*http://support.spss.com/Tech/default.asp*/. > > > > > > !ENDDEFINE. > > > > > > SET PRINTBACK=ON /MPRINT=ON. > > > !seg xy= filter1. > > > !seg xy=filter2. > > > !seg xy=fillter3. > > > SET MPRINT= OFF. > > > > > > > ===================== > > 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 |
|
Hi,
If you want the percentage men/women of the total number of cases, you could use something like: compute dummy = 1. /* the dummy constant collapses the file into one record. aggregate outfile = * mode=addvariables / break = dummy / n_tot = n. aggregate outfile = * / break = sex / n_group = n. compute pct = (n_group / n_tot) * 100. formats pct (pct5.2). exe. Cheers!! Albert-Jan --- On Sat, 8/9/08, J Sutar <[hidden email]> wrote: > From: J Sutar <[hidden email]> > Subject: Re: Using Macro to define file names > To: [hidden email] > Date: Saturday, August 9, 2008, 4:47 PM > I agree. AGGREGATE followed by SAVE TRANSLATE would be a > better solution. > > How do I use AGGREGATE to get the percentage of cases? > > (I've only started using AGGREGATE command this week). > > By the way you're solution for the macro worked just > fine, thanks. > > Jignesh > > 2008/8/6 Albert-jan Roskam <[hidden email]> > > > Hi, > > > > I'd really use AGGREGATE and SAVE TRANSLATE for > this. Don't you run into > > asynchronicity problems with syntax/script? > > > > DEFINE !seg (!POSITIONAL !charend('/') > /!POSITIONAL !cmdend). > > > > [...] > > !seg filter1 / test file. > > > > might work.. > > > > Cheers!! > > Albert-Jan > > > > --- On Wed, 8/6/08, J Sutar <[hidden email]> > wrote: > > > > > From: J Sutar <[hidden email]> > > > Subject: Re: Using Macro to define file names > > > To: [hidden email] > > > Date: Wednesday, August 6, 2008, 7:26 PM > > > I've made some progress after reading the > Command Syntax > > > Reference. > > > Currently my setup uses positional arguments and > therefore > > > I can only define > > > a one-word file name for the second positional > argument. I > > > need a helping > > > hand so that the macro can facilitate file names > of > > > multiple words. > > > > > > > > > DEFINE !seg (!POSITIONAL !tokens(1) /!POSITIONAL > !tokens > > > (1)). > > > > > > OUTPUT CLOSE ALL. > > > OUTPUT NEW. > > > > > > USE ALL. > > > COMPUTE > filter_$=!CONCAT("(",!1,"=1)"). > > > FILTER BY filter_$. > > > EXECUTE . > > > > > > FREQ V1. > > > > > > USE ALL. > > > FILTER OFF. > > > > > > > > > SCRIPT "C:\Program > > > > Files\SPSS\Scripts\Export_to_Excel_(BIFF).SBS" > > > > /!CONCAT("('C:\temp\",!2,".xls')"). > > > > > > !ENDDEFINE. > > > > > > SET PRINTBACK=ON /MPRINT=ON. > > > !seg filter1 test. > > > !seg filter2 male > > > !seg filter3 female > > > SET MPRINT= OFF. > > > > > > 2008/8/6 J Sutar <[hidden email]> > > > > > > > Hi, > > > > > > > > I'm trying to set up a macro which > produces > > > frequency tables on various > > > > filters and then exports each table to > individual > > > excel files. > > > > > > > > The macro syntax below works fine but I need > to tweak > > > it a little so I can > > > > define a file name for each export. > > > > > > > > This is my first attempt in writing a macro, > I'm > > > still unclear exactly what > > > > tokens/charend/enclose & cmdend all mean > and how > > > to use them. > > > > > > > > Here is the syntax: > > > > > > > > DEFINE !seg (xy=!tokens(1)). > > > > > > > > OUTPUT NEW. > > > > > > > > USE ALL. > > > > COMPUTE > > > > filter_$=!CONCAT("(",!xy,"=1)"). > > > > FILTER BY filter_$. > > > > EXECUTE . > > > > > > > > FREQ V1. > > > > > > > > USE ALL. > > > > FILTER OFF. > > > > > > > > SCRIPT "C:\Program > > > > Files\SPSS\Scripts\Export_to_Excel_(BIFF).SBS" > > > > /("C:\temp\First file > output.xls"). > > > > > /*http://support.spss.com/Tech/default.asp*/. > > > > > > > > !ENDDEFINE. > > > > > > > > SET PRINTBACK=ON /MPRINT=ON. > > > > !seg xy= filter1. > > > > !seg xy=filter2. > > > > !seg xy=fillter3. > > > > SET MPRINT= OFF. > > > > > > > > > > ===================== > > > 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 ===================== 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 |
