dynamic creation of upper bounds of vector

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

dynamic creation of upper bounds of vector

Krampner, John

I am trying to create a vector whose upper bounds change. I am using a macro.

Here is a simple version of what I am trying to do:

 

compute #UpperBounds=Cellsize.

 

DEFINE ExperimentalMacro (arg1 = !TOKENS(1)

            !concat("vector MadeUp(",!arg1,").")

!ENDDEFINE.

ExperimentalMacro arg1 = #UpperBounds.

 

The above code, of course, doesn’t work.

 

In other words, I want to run a line saying: Vector MadeUp(<whatever value of Cellsize is>).

 

Does anyone have any tips?

 

John Krampner

 

Center for Economic Opportunity

Human Resources Administration

City of New York

 

Reply | Threaded
Open this post in threaded view
|

AW: dynamic creation of upper bounds of vector

la volta statistics

Hi John

 

It is not completely clear what you want. It looks like you want to create a vector that refers to  variables MadeUp_1 to MadeUp_<Whatever value of CellSize is>. Maybe the following syntax helps you to get you on the way for what you want.

Hope this helps, Christian

 

 

DATA LIST LIST /CellSize(f8.0).

BEGIN DATA

2

3

4

END DATA.

 

compute #UpperBounds=Cellsize.

 

Do if $Casenum = 1.

+ Write Outfile 'C:\Temp\Temp1.sps'  /"DEFINE !ExperimentalMacro()"/'vector MadeUp('#UpperBounds').' /"!ENDDEFINE.".

End if.

Exec.

Include 'C:\Temp\Temp1.sps'  .

!ExperimentalMacro.

 

 

 

**********************************
la volta statistics

Christian Schmidhauser, Dr.phil.II
Weinbergstrasse 108
CH-8006 Zürich
Tel: +41 (043) 233 98 01
Fax: +41 (043) 233 98 02
email:
[hidden email] 
Web: www.lavolta.ch


Von: SPSSX(r) Discussion [mailto:[hidden email]] Im Auftrag von Krampner, John
Gesendet: Montag, 20. April 2009 22:40
An: [hidden email]
Betreff: dynamic creation of upper bounds of vector

 

I am trying to create a vector whose upper bounds change. I am using a macro.

Here is a simple version of what I am trying to do:

 

compute #UpperBounds=Cellsize.

 

DEFINE ExperimentalMacro (arg1 = !TOKENS(1)

            !concat("vector MadeUp(",!arg1,").")

!ENDDEFINE.

ExperimentalMacro arg1 = #UpperBounds.

 

The above code, of course, doesn’t work.

 

In other words, I want to run a line saying: Vector MadeUp(<whatever value of Cellsize is>).

 

Does anyone have any tips?

 

John Krampner

 

Center for Economic Opportunity

Human Resources Administration

City of New York

 

Reply | Threaded
Open this post in threaded view
|

Re: dynamic creation of upper bounds of vector

Krampner, John

Thanks very much for your response. This is similar to what I am looking to do, but not quite. What I want to do is to be able to capture a number which will be the upper bounds of a vector, and then use it to either create or declare a vector in a case where I won’t know the value of the upper bounds variable until the program runs.

 

So

compute #UpperBounds = 10.

 

Would be used to create a vector that would be the equivalent of

 

ExampleVector(#UpperBounds)  

To equal:   ExampleVector(10).

Or

ExampleVector=ExampleVector1 to Concat(“ExampleVector”,String(#UpperBounds,F8.0)).  

To equal :  ExampleVector=ExampleVector1 to ExampleVector10.

 

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of la volta statistics
Sent: Tuesday, April 21, 2009 4:36 AM
To: [hidden email]
Subject: AW: dynamic creation of upper bounds of vector

 

Hi John

 

It is not completely clear what you want. It looks like you want to create a vector that refers to  variables MadeUp_1 to MadeUp_<Whatever value of CellSize is>. Maybe the following syntax helps you to get you on the way for what you want.

Hope this helps, Christian

 

 

DATA LIST LIST /CellSize(f8.0).

BEGIN DATA

2

3

4

END DATA.

 

compute #UpperBounds=Cellsize.

 

Do if $Casenum = 1.

+ Write Outfile 'C:\Temp\Temp1.sps'  /"DEFINE !ExperimentalMacro()"/'vector MadeUp('#UpperBounds').' /"!ENDDEFINE.".

End if.

Exec.

Include 'C:\Temp\Temp1.sps'  .

!ExperimentalMacro.

 

 

 

**********************************
la volta statistics

Christian Schmidhauser, Dr.phil.II
Weinbergstrasse 108
CH-8006 Zürich
Tel: +41 (043) 233 98 01
Fax: +41 (043) 233 98 02
email:
[hidden email] 
Web: www.lavolta.ch


Von: SPSSX(r) Discussion [mailto:[hidden email]] Im Auftrag von Krampner, John
Gesendet: Montag, 20. April 2009 22:40
An: [hidden email]
Betreff: dynamic creation of upper bounds of vector

 

I am trying to create a vector whose upper bounds change. I am using a macro.

Here is a simple version of what I am trying to do:

 

compute #UpperBounds=Cellsize.

 

DEFINE ExperimentalMacro (arg1 = !TOKENS(1)

            !concat("vector MadeUp(",!arg1,").")

!ENDDEFINE.

ExperimentalMacro arg1 = #UpperBounds.

 

The above code, of course, doesn’t work.

 

In other words, I want to run a line saying: Vector MadeUp(<whatever value of Cellsize is>).

 

Does anyone have any tips?

 

John Krampner

 

Center for Economic Opportunity

Human Resources Administration

City of New York

 

Reply | Threaded
Open this post in threaded view
|

AW: dynamic creation of upper bounds of vector

la volta statistics

What about this solution? Hope this helps,

Christian

 

DATA LIST LIST /CellSize(f8.0).

BEGIN DATA

12

END DATA.

 

 

String MyVector (A200).

 

compute #UpperBounds=Cellsize.

Format #UpperBounds(F8.0).

 

COMPUTE myVECTOR = CONCAT('Vector = ExampleVector_1 to  ExampleVector_',RTRIM(LTRIM(STRING(#UpperBounds,F8.0))),'.' ).

Exec.

 

Do if $Casenum = 1.

+ Write Outfile 'd:\Temp\Temp1.sps'  /"DEFINE !ExperimentalMacro()"/myVector /"!ENDDEFINE.".

End if.

Exec.

 

Include 'd:\Temp\Temp1.sps'  .

 

!ExperimentalMacro.

 

 

 

 


Von: SPSSX(r) Discussion [mailto:[hidden email]] Im Auftrag von Krampner, John
Gesendet: Dienstag, 21. April 2009 14:59
An: [hidden email]
Betreff: Re: dynamic creation of upper bounds of vector

 

Thanks very much for your response. This is similar to what I am looking to do, but not quite. What I want to do is to be able to capture a number which will be the upper bounds of a vector, and then use it to either create or declare a vector in a case where I won’t know the value of the upper bounds variable until the program runs.

 

So

compute #UpperBounds = 10.

 

Would be used to create a vector that would be the equivalent of

 

ExampleVector(#UpperBounds)  

To equal:   ExampleVector(10).

Or

ExampleVector=ExampleVector1 to Concat(“ExampleVector”,String(#UpperBounds,F8.0)).  

To equal :  ExampleVector=ExampleVector1 to ExampleVector10.

 

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of la volta statistics
Sent: Tuesday, April 21, 2009 4:36 AM
To: [hidden email]
Subject: AW: dynamic creation of upper bounds of vector

 

Hi John

 

It is not completely clear what you want. It looks like you want to create a vector that refers to  variables MadeUp_1 to MadeUp_<Whatever value of CellSize is>. Maybe the following syntax helps you to get you on the way for what you want.

Hope this helps, Christian

 

 

DATA LIST LIST /CellSize(f8.0).

BEGIN DATA

2

3

4

END DATA.

 

compute #UpperBounds=Cellsize.

 

Do if $Casenum = 1.

+ Write Outfile 'C:\Temp\Temp1.sps'  /"DEFINE !ExperimentalMacro()"/'vector MadeUp('#UpperBounds').' /"!ENDDEFINE.".

End if.

Exec.

Include 'C:\Temp\Temp1.sps'  .

!ExperimentalMacro.

 

 

 

**********************************
la volta statistics

Christian Schmidhauser, Dr.phil.II
Weinbergstrasse 108
CH-8006 Zürich
Tel: +41 (043) 233 98 01
Fax: +41 (043) 233 98 02
email:
[hidden email] 
Web: www.lavolta.ch


Von: SPSSX(r) Discussion [mailto:[hidden email]] Im Auftrag von Krampner, John
Gesendet: Montag, 20. April 2009 22:40
An: [hidden email]
Betreff: dynamic creation of upper bounds of vector

 

I am trying to create a vector whose upper bounds change. I am using a macro.

Here is a simple version of what I am trying to do:

 

compute #UpperBounds=Cellsize.

 

DEFINE ExperimentalMacro (arg1 = !TOKENS(1)

            !concat("vector MadeUp(",!arg1,").")

!ENDDEFINE.

ExperimentalMacro arg1 = #UpperBounds.

 

The above code, of course, doesn’t work.

 

In other words, I want to run a line saying: Vector MadeUp(<whatever value of Cellsize is>).

 

Does anyone have any tips?

 

John Krampner

 

Center for Economic Opportunity

Human Resources Administration

City of New York