```Date: Thu, 14 May 2009 17:47:08 -0400 Reply-To: Art@DrKendall.org Sender: "SPSSX(r) Discussion" From: Art Kendall Subject: Re: Macro Problem Comments: To: angelina garnica In-Reply-To: Content-type: multipart/alternative; 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 > > I´ve 2 sets of variables vector c (codes name ej 001_001, 001_002 ...) > and vector d (amount of codes) > I need to create a variable c_001_001 .... one for each value of > vector c equals to vector b position. > > here is an example for 2 variables of my work base > > id v1 > v2 > b1 > b2 > 1 001_001 001_001 727 415 > 2 001_002 001_008 530 > 854 > 3 080_000 000_000 1500 260 > > > > The file I need should look like this: > > id c_001_001 c_001_002 > 1 1142 > 0 > 2 0 530 > 3 0 0 > > > > The sintaxis work well but i need do it for each code. > > well i hope by more clear, thanks > > Angelina > > > On Thu, May 14, 2009 at 11:32 AM, Art Kendall > wrote: > > 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 > > > [text/html] ```

Back to: Top of message | Previous page | Main SPSSX-L page