Vector in macro?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Vector in macro?

Ruben Geert van den Berg
Dear all,

I'd like to obtain means tables of 'power_01' by 'cm1', 'power_02' by 'cm2' and so on. I tried it with the vector function but apparently, I can use vector only for variable transformation functions.
 
***Doesn't work.

vector pim=power_01 to power_13.
vector cm=cm1 to cm13.
 
loop #i=1 to 13.
mea pim(#i) by cm(#i).
end loop.
exe.
 
***End.

So then I undertook a rather desperate attempt to do it with a macro but I don't know how to write macros yet so it may look silly.
 
***Ruben's desparate attempt.
 
define meanstables (rows=!charend('/') /columns=!charend('/'))
!do !var=1 !to length(rows)
mea !rows(!var) by !columns(!var).
!doend
!enddefine.
 
meanstables rows= power_1 to power_13/columns=cm1 to cm13/.
 
***End.
 
Could anybody please point out how this could be done?
 
TIA and a happy weekend to all!
 
Ruben


Express yourself instantly with MSN Messenger! MSN Messenger
Reply | Threaded
Open this post in threaded view
|

Re: Vector in macro?

Spousta Jan
Hi Ruben,
 
define meanstables ()
!do !i=1 !to 13
!let !r = !concat("power_", !i)
!let !c = !concat("cm", !i)
mean !r by !c.
!doend
!enddefine.
 
meanstables .
 
Best regards,
 
Jan


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ruben van den Berg
Sent: Friday, September 11, 2009 1:45 PM
To: [hidden email]
Subject: Vector in macro?

Dear all,

I'd like to obtain means tables of 'power_01' by 'cm1', 'power_02' by 'cm2' and so on. I tried it with the vector function but apparently, I can use vector only for variable transformation functions.
 
***Doesn't work.

vector pim=power_01 to power_13.
vector cm=cm1 to cm13.
 
loop #i=1 to 13.
mea pim(#i) by cm(#i).
end loop.
exe.
 
***End.

So then I undertook a rather desperate attempt to do it with a macro but I don't know how to write macros yet so it may look silly.
 
***Ruben's desparate attempt.
 
define meanstables (rows=!charend('/') /columns=!charend('/'))
!do !var=1 !to length(rows)
mea !rows(!var) by !columns(!var).
!doend
!enddefine.
 
meanstables rows= power_1 to power_13/columns=cm1 to cm13/.
 
***End.
 
Could anybody please point out how this could be done?
 
TIA and a happy weekend to all!
 
Ruben


Express yourself instantly with MSN Messenger! MSN Messenger  

_____________

Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem.

P Jste si jisti, že opravdu potřebujete vytisknout tuto zprávu a/nebo její přílohy? Myslete na přírodu.

 


This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission.

 

P Are you sure that you really need a print version of this message and/or its attachments? Think about nature.

-.- --
Reply | Threaded
Open this post in threaded view
|

Re: Vector in macro?

Ruben Geert van den Berg
Dear Jan,
 
Thanks a lot for the macro, but there's 2 minor issues:
 
1) it doesn't work since the 'power_variables' start with power_01 and the concat renders power_1 instead.
 
2) I was hoping for something more general so the variables don't necessarily need similar names except for the suffixes. With 'do repeat' and 'vector' the variables can have any name, like
 
vector pet=dog to whale.
loop #i = 1 to 4.
comp pet(#i)=#i.
end loop.
exe.
 
Something like this could be applied to all sorts of analyses following the same structure (like a bunch of single regressions with the same dependent variable and different independents). I could make a vector of independents, insert the vector name in the regression command and then simply loop through the regression analyses. A workaround could be to rename the variables but I'd rather avoid that if possible.
 
Have a nice weekend!
 
Ruben



 



 

Date: Fri, 11 Sep 2009 14:07:27 +0200
From: [hidden email]
Subject: Re: Vector in macro?
To: [hidden email]

Hi Ruben,
 
define meanstables ()
!do !i=1 !to 13
!let !r = !concat("power_", !i)
!let !c = !concat("cm", !i)
mean !r by !c.
!doend
!enddefine.
 
meanstables .
 
Best regards,
 
Jan


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ruben van den Berg
Sent: Friday, September 11, 2009 1:45 PM
To: [hidden email]
Subject: Vector in macro?

Dear all,

I'd like to obtain means tables of 'power_01' by 'cm1', 'power_02' by 'cm2' and so on. I tried it with the vector function but apparently, I can use vector only for variable transformation functions.
 
***Doesn't work.

vector pim=power_01 to power_13.
vector cm=cm1 to cm13.
 
loop #i=1 to 13.
mea pim(#i) by cm(#i).
end loop.
exe.
 
***End.

So then I undertook a rather desperate attempt to do it with a macro but I don't know how to write macros yet so it may look silly.
 
***Ruben's desparate attempt.
 
define meanstables (rows=!charend('/') /columns=!charend('/'))
!do !var=1 !to length(rows)
mea !rows(!var) by !columns(!var).
!doend
!enddefine.
 
meanstables rows= power_1 to power_13/columns=cm1 to cm13/.
 
***End.
 
Could anybody please point out how this could be done?
 
TIA and a happy weekend to all!
 
Ruben


Express yourself instantly with MSN Messenger! MSN Messenger  

_____________

Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem.

P Jste si jisti, že opravdu potřebujete vytisknout tuto zprávu a/nebo její přílohy? Myslete na přírodu.

 


This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission.

 

P Are you sure that you really need a print version of this message and/or its attachments? Think about nature.

-.- --


Express yourself instantly with MSN Messenger! MSN Messenger