Good afternoon,
I would like to save some data subsets into a series of Excel files - by site (8 sites) where anydqflag=1. Currently the syntax is a series of temp. select if statements followed by the full save translate for each new file name. It seems that it could be simply done using split file and filter, but I am not sure how to pass the full file path/names so that data for site1 goes to the filename for site1, and so on. sort cases by site. split file by site filter by anydqflag. ==================> something here to pass the names...?? ==================> the effect I want is for each site save translate /outfile = 'file for site1.xls'...<the rest of the command> save translate /outfile = 'file for site2.xls'..<the rest of the command> ...<the rest of the files> save translate /outfile = 'file for site8.xls'...<the rest of the command> Could this be done using do repeat (site=1 - 8 and file='full file path' for sites 1-8)? Or is there a better way? I am not sure if we have Python, so a solution without it would be more helpful Thanks! Melissa This correspondence contains proprietary information some or all of which may be legally privileged; it is for the intended recipient only. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this correspondence and completely dispose of the correspondence immediately. Please notify the sender if you have received this email in error. NOTE: Messages to or from the State of Connecticut domain may be subject to the Freedom of Information statutes and regulations. ===================== 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 presume "site" is a numeric variable ranging for 1 to 8 (if it isn't you can use AUTORECODE to meet those requirements). If you don't mind inputting the total number of different files, it is a fairly simple task with a macro. Something list this (untested):
***********************************************. DEFINE !SiteSavXLS (N = !TOKENS(1) /Handle = !DEFAULT ("Your Path You Want") !TOKENS(1) ) !DO !I = 1 !TO !N TEMPORARY. SELECT IF (Site = !I) AND (anydqflag = 1). !LET !OutF = !CONCAT(!Handle,'\File for site',!I,'.xls') SAVE TRANSLATE /OUTFILE = !OutF <the rest of the command> EXECUTE. !DOEND !ENDDEFINE. !SiteSavXLS N = 8. ***********************************************. Basically is just does the loop from 1 to "N" within the macro and makes the file name alittle simpler. Just alittle more concise than writing it out 8 times. Python you could get more fancy and have the filename actually correspond to the value label of the site I imagine. |
Free forum by Nabble | Edit this page |