LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2009)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 21 May 2009 12:06:07 -0400
Reply-To:     Art@DrKendall.org
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Art Kendall <Arthur.Kendall@VERIZON.NET>
Subject:      Re: Macro Problem
Comments: To: angelina garnica <angelina.work08@gmail.com>
In-Reply-To:  <c9a06cdd0905150501n24a5319bp99b093e8fa76c646@mail.gmail.com>
Content-type: multipart/alternative;

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!! > But i have more than 100 codes (001_001) so i was looking for a macro > that can do it once. > > Thanks > Angelina > > On Thu, May 14, 2009 at 6:47 PM, Art Kendall > <Arthur.Kendall@verizon.net <mailto:Arthur.Kendall@verizon.net>> wrote: > > 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 <Art@drkendall.org >> <mailto:Art@drkendall.org>> 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