list of vars

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

list of vars

cristiano1974
Dear Lister,
 another question about macro, and I'd like to use a list of vars in macro/syntax. 

The length of list of vars could be long, like 100 vars. 

But I don't have v1...v100, but I have as names: varA,varH,xyz,hht,....

I'd like to use like varA to hht,  but it doesnt work, I think.

My first use of this macro is inside a AGGREGATE procedure. I've tried to use vector() but it's not a correct way.

define !aggr(!pos !tokens(1) )
vector lista = B02_050 to HHT.
DATASET ACTIVATE DataSet0.
DATASET DECLARE test.
AGGREGATE
  /OUTFILE='test'
  /BREAK=!1
!do !i= 1 !to !length(lista)
 / lista(!i)  = MAX(lista(!i)) 
!doend.
!enddefine.

!aggr cod.


Any kind of help is really appreciated, thanks.

C
 
Reply | Threaded
Open this post in threaded view
|

Re: list of vars

Marks, Jim

Cristiano:

 

The correct form for a list processing loop in a macro is

 

DEFINE thelist  (!POS !CHAREND (‘/’))

 

!DO !i  !IN (!1)

...

!DOEND

!ENDDEFINE.

 

thelist varA varX xyz htt /.

 

When you call the macro, you can supply the list of items

 

I’m not sure what you are trying to accomplish with your macro, so I’m not sure how to edit your example for the aggregate command.

 

Jim Marks

Director, Market Research

x1616

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Cristiano
Sent: Wednesday, February 03, 2010 11:20 AM
To: [hidden email]
Subject: list of vars

 

Dear Lister,

 another question about macro, and I'd like to use a list of vars in macro/syntax. 

 

The length of list of vars could be long, like 100 vars. 

 

But I don't have v1...v100, but I have as names: varA,varH,xyz,hht,....

 

I'd like to use like varA to hht,  but it doesnt work, I think.

 

My first use of this macro is inside a AGGREGATE procedure. I've tried to use vector() but it's not a correct way.

 

define !aggr(!pos !tokens(1) )

vector lista = B02_050 to HHT.

DATASET ACTIVATE DataSet0.

DATASET DECLARE test.

AGGREGATE

  /OUTFILE='test'

  /BREAK=!1

!do !i= 1 !to !length(lista)

 / lista(!i)  = MAX(lista(!i)) 

!doend.

!enddefine.

 

!aggr cod.

 

 

Any kind of help is really appreciated, thanks.

 

C