|
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
|
|
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. **********************************
Christian
Schmidhauser, Dr.phil.II Von: SPSSX(r)
Discussion [mailto:[hidden email]] Im
Auftrag von 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 Human Resources Administration City of |
|
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
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.
**********************************
Christian
Schmidhauser, Dr.phil.II Von: SPSSX(r)
Discussion [mailto:[hidden email]] Im
Auftrag von 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
|
|
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 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 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. **********************************
Christian Schmidhauser,
Dr.phil.II Von: SPSSX(r)
Discussion [mailto:[hidden email]] Im
Auftrag von 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 Human Resources Administration City of |
| Free forum by Nabble | Edit this page |
