|
Hello: I am new to SPSS (old SAS user). Please can someone help with
this dilemma? I need to loop through two lists, first is a variable flag, second is a filepath. I have an outer loop to go through the vars; I do NOT want to have an inner loop to go through all 9 filepaths at once. I need to access the var flag, unduplicate/aggregate, and save to the approriate file path. So SELECT A_flg then OUTFILE A_filepath. HEre is what I have so far. It works fine except for the filepath. I have experimented with loops, vectors, indexes, but can't seem to get it. Anyone out there that can help?? The BIG problem is right before AGGREGATE. /**Macro to Get file, SELECT variable based on if flag is set to 1, unduplicate cases, OUTFILE to specific file for that flag. DEFINE !Undupflg (flags= !CHAREND ('/') /fpaths=!CMDEND ). !DO !flag !IN (!flags). GET FILE='C:\Work Files\REPORTS.sav' /keep= Cum_flg R12_flg A_flg B_flg C_flg D_flg E_flg F_flg G_flg H_flg I_flg. STRING program_category (A10). COMPUTE program_category = 'AA_all'. /** (This will be changed to increment also, eventually). SELECT IF (!flag =1). (Get variables, if flag is set to one, select case - increment through A-I flags. This works fine!). SORT CASES BY ssn (a) Cum_flg (d). MATCH FILES FILE=* /BY=ssn /FIRST=first_ssn. SELECT IF (first_ssn=1). ?????????????????????????????? /* THE BIG PROBLEM!! How do I get this to increment through A_aggre to I_aggre ?????????????????????????????? /* in sync with the SELECT IF (!flag). Don't want a LOOP here to run thru all aggre files. AGGREGATE /OUTFILE= ( to filenames A_aggre thru I_aggre. i.e. A_flg goes to A_aggre file, etc). /BREAK=program_category /Cum_flg_total=SUM(Cum_flg) /R12_flg_total=SUM(R12_flg). !DOEND. !ENDDEFINE. SET MPRINT=ON. !Undupflg flags=A_flg B_flg C_flg D_flg E_flg F_flg G_flg H_flg I_flg /fpaths=A_aggre B_aggre C_aggre D_aggre E_aggre F_aggre G_aggre H_aggre I_aggre. ===================== 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 |
|
Administrator
|
I must confess that I got a bit bogged down while reading through your macro. But if I followed, the crux of the problem that you want to loop through the two lists in step, is that right? If it is, why not hand the macro a list containing A B C D E F G H I, and then use !CONCAT to construct the flag and file names? E.g., something like: DEFINE !Undupflg (letters=!CMDEND ). !DO !L !IN (!letters). !LET !flag = !CONCAT(!L,"_flag") !LET !path = !CONCAT(!L,"_aggre") etc. With !CONCAT, it is sometimes necessary to fiddle around with !QUOTE and !UNQUOTE to get things working properly, and I may not have it quite right there. Looking at example I have suggests it might have to be done like this for the path: !LET !path = !QUOTE(!CONCAT(!UNQUOTE(!L),"_aggre")) HTH.
--
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 |
