|
Hi, I´m new using macro. After a lot of trys I write this code, but it dosen't work.
*////////// PRUEBA_1. DEFINE !codigos (vnames=!CMDEND) VECTOR c=v1 TO v5. VECTOR d=imp_conc1 TO imp_conc5. !DO !cnt=1 !TO 5 IF (c(!cnt)) = !QUOTE(!vnames). COMPUTE !CONCAT('c_', !vnames) = d(!cnt). !DOEND !ENDDEFINE. *//////////. SET MPRINT = ON. !codigos vnames = 001_001 001_002 001_003. (I have more than 100 codes) The idea is repeat this sintax for all codes. VECTOR c=v1 TO v5. VECTOR d=imp_conc1 TO imp_conc5. LOOP cnt=1 TO 5. DO IF (c(cnt)) = '001-001'. COMPUTE c_001_001= d(cnt). END IF. END LOOP. EXECUTE. I hope you can help me. Angelina |
|
I only have an impression of what you are trying to do. Please post a
more detailed description of what you are trying to do and what you are going to with the resulting variables. It appears that you have 3 sets of 5 variables and are trying to get count of the occurrence of those codes in each set. If that is correct and that is all you need, it is possible that using AUTORECODE with the GROUP subcommand follow by MULT RESPONSE will do what you want. Art Kendall Social Research Consultants angelina garnica wrote: > Hi, I´m new using macro. After a lot of trys I write this code, but it > dosen't work. > > *////////// PRUEBA_1. > DEFINE !codigos (vnames=!CMDEND) > VECTOR c=v1 TO v5. > VECTOR d=imp_conc1 TO imp_conc5. > !DO !cnt=1 !TO 5 > IF (c(!cnt)) = !QUOTE(!vnames). > COMPUTE !CONCAT('c_', !vnames) = d(!cnt). > !DOEND > !ENDDEFINE. > *//////////. > > SET MPRINT = ON. > !codigos vnames = 001_001 001_002 001_003. > (I have more than 100 codes) > > The idea is repeat this sintax for all codes. > > VECTOR c=v1 TO v5. > VECTOR d=imp_conc1 TO imp_conc5. > LOOP cnt=1 TO 5. > DO IF (c(cnt)) = '001-001'. > COMPUTE c_001_001= d(cnt). > END IF. > END LOOP. > EXECUTE. > > I hope you can help me. > > Angelina ===================== 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
Art Kendall
Social Research Consultants |
|
I s this what you want to do?
For each of the codes that occur in the set c, find the sum of the values in the set d? b? that have the same index? b1 goes with v1, b2 does with v2? using "d" instead of "b" is this what you want for a single code that occurs anywhere in set c? VECTOR c=v1 TO v5. VECTOR d=imp_conc1 TO imp_conc5. LOOP cnt=1 TO 5. DO IF (c(cnt)) = '001-001'. COMPUTE c_001_001= c_001_001 +d(cnt). END IF. END LOOP. EXECUTE. Art Kendall Social Research Consultants angelina garnica wrote: Hallo Art, my problem is more complicated and my english is not so good, I'll try to explain it better |
|
Sorry, I did not see your post until now since it was not in the
mailbox I filter the SPSSX-L mail to. It was in the mailbox for
messages from unanticipated senders.
A lot depends on what you are going to do with the resulting variables if this is something you will not need very often I would not bother with a macro. If you do not already know the range of codes. First AUTORECODE the set of variables "c" using the GROUP and PRINT options then inspect the listing for the actual number of codes found. or the alphabetically maximum code. If you want only as many variables as there are codes, name the new variables based on the AUTO RECODEd variables. then wrap the syntax you have in another vector. something like vector myautocode (77, f8). Alternatively, you could copy the list of actually occuring codes from the autorecode and paste them into a syntax window, or if you want all codes in a range. numeric c_001_001 to c_001_123 (f8). or vector c_001_001 to c_001_123 (f8). etc. Alternatively, you could copy the list of actually occuring codes from the autorecode and paste them into a syntax window, Art Kendall Social Research Consultants angelina garnica wrote: Yes, that is exact what i want!! |
| Free forum by Nabble | Edit this page |
