MACRO value as a String

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

MACRO value as a String

Jonathan Olmsted
Greetings List!

I am working with a macro to reproduce the creation of a custom report
for a list of variables, using REPORT, based on some values calculated
several AGGREGATE functions up from my raw data.

I invoke my macro with :

!varlst varnam= v1 v2 .

and it is defined as

*just a snippet of the syntax.
DEFINE !varlst (varnam=!CMDEND)
!DO !vname !IN (!varnam)
GET FILE= 'c:file\file\file.sav'.
COMPUTE X1 = !vname.
* snip snip.


Everything is functioning properly, but I am trying to include the
variable name (e.g. v1) in the reports generated by my macro so that I
can easily distinguish amongst them.  I have tried creating a string
variable with the value !vname and was not able to get this to work.
Additionally, I have tried to use the STRING subcommand in REPORT, but
still was not able to get variable name to print out in each iterations.

I am on a machine w/o SPSS right now, so I can't check to see exactly
which error message I get, but if I remember correctly, it is related to
variable type.

I should note that everything else is functioning 100% correctly, the
operations are performed on the correct variables, it is just being able
to include !vname as a string.

Thanks for you help

Jonathan Olmsted
Reply | Threaded
Open this post in threaded view
|

Re: MACRO value as a String

Hal 9000
It looks like you're trying to assign a string value to a numeric variable.
When you compute a var without first declaring it with the String command,
it's automatically numeric.

If you declare it with String, then you still need to use !quote() to
identify !vname as a string value. See if this helps.

-Gary


On 10/18/06, Jonathan Paul Olmsted <[hidden email]> wrote:

>
> Greetings List!
>
> I am working with a macro to reproduce the creation of a custom report
> for a list of variables, using REPORT, based on some values calculated
> several AGGREGATE functions up from my raw data.
>
> I invoke my macro with :
>
> !varlst varnam= v1 v2 .
>
> and it is defined as
>
> *just a snippet of the syntax.
> DEFINE !varlst (varnam=!CMDEND)
> !DO !vname !IN (!varnam)
> GET FILE= 'c:file\file\file.sav'.
> COMPUTE X1 = !vname.
> * snip snip.
>
>
> Everything is functioning properly, but I am trying to include the
> variable name (e.g. v1) in the reports generated by my macro so that I
> can easily distinguish amongst them.  I have tried creating a string
> variable with the value !vname and was not able to get this to work.
> Additionally, I have tried to use the STRING subcommand in REPORT, but
> still was not able to get variable name to print out in each iterations.
>
> I am on a machine w/o SPSS right now, so I can't check to see exactly
> which error message I get, but if I remember correctly, it is related to
> variable type.
>
> I should note that everything else is functioning 100% correctly, the
> operations are performed on the correct variables, it is just being able
> to include !vname as a string.
>
> Thanks for you help
>
> Jonathan Olmsted
>
Reply | Threaded
Open this post in threaded view
|

Re: MACRO value as a String

Hal 9000
If that didn't make sense, then send me sample data that approximates your
real data, and I'll make it work. However, it looks like you know what
you're doing. I just don't like the feeling of giving advice that might not
be helpful, or even more confusing. But, without a very accurate description
of the data, or (best) sample data, you're not going to get answers from the
REAL pros here because there's not enough for them to sink their teeth into.
But feel free to mail me if you get stuck.

Gary


On 10/18/06, Hal 9000 <[hidden email]> wrote:

>
> It looks like you're trying to assign a string value to a numeric
> variable. When you compute a var without first declaring it with the String
> command, it's automatically numeric.
>
> If you declare it with String, then you still need to use !quote() to
> identify !vname as a string value. See if this helps.
>
> -Gary
>
>
>  On 10/18/06, Jonathan Paul Olmsted <[hidden email]> wrote:
> >
> > Greetings List!
> >
> > I am working with a macro to reproduce the creation of a custom report
> > for a list of variables, using REPORT, based on some values calculated
> > several AGGREGATE functions up from my raw data.
> >
> > I invoke my macro with :
> >
> > !varlst varnam= v1 v2 .
> >
> > and it is defined as
> >
> > *just a snippet of the syntax.
> > DEFINE !varlst (varnam=!CMDEND)
> > !DO !vname !IN (!varnam)
> > GET FILE= 'c:file\file\file.sav'.
> > COMPUTE X1 = !vname.
> > * snip snip.
> >
> >
> > Everything is functioning properly, but I am trying to include the
> > variable name (e.g. v1) in the reports generated by my macro so that I
> > can easily distinguish amongst them.  I have tried creating a string
> > variable with the value !vname and was not able to get this to work.
> > Additionally, I have tried to use the STRING subcommand in REPORT, but
> > still was not able to get variable name to print out in each iterations.
> >
> > I am on a machine w/o SPSS right now, so I can't check to see exactly
> > which error message I get, but if I remember correctly, it is related to
> >
> > variable type.
> >
> > I should note that everything else is functioning 100% correctly, the
> > operations are performed on the correct variables, it is just being able
> > to include !vname as a string.
> >
> > Thanks for you help
> >
> > Jonathan Olmsted
> >
>
>
Reply | Threaded
Open this post in threaded view
|

Re: MACRO value as a String

Jonathan Olmsted
...I suppose I shouldn't be surprised that I get a solution from Hal 9000.

Seriously though,  Thanks a lot Gary and sorry I didn't have a chance to
run it before this AM.  It worked as it should have.  Now that I look at
it I have no idea why I didn't do this, but thank goodness for the list.

Thanks all,
Jonathan Olmsted

Hal 9000 wrote:

> If that didn't make sense, then send me sample data that approximates
> your
> real data, and I'll make it work. However, it looks like you know what
> you're doing. I just don't like the feeling of giving advice that
> might not
> be helpful, or even more confusing. But, without a very accurate
> description
> of the data, or (best) sample data, you're not going to get answers
> from the
> REAL pros here because there's not enough for them to sink their teeth
> into.
> But feel free to mail me if you get stuck.
>
> Gary
>
>
> On 10/18/06, Hal 9000 <[hidden email]> wrote:
>>
>> It looks like you're trying to assign a string value to a numeric
>> variable. When you compute a var without first declaring it with the
>> String
>> command, it's automatically numeric.
>>
>> If you declare it with String, then you still need to use !quote() to
>> identify !vname as a string value. See if this helps.
>>
>> -Gary
>>
>>
>>  On 10/18/06, Jonathan Paul Olmsted <[hidden email]> wrote:
>> >
>> > Greetings List!
>> >
>> > I am working with a macro to reproduce the creation of a custom report
>> > for a list of variables, using REPORT, based on some values calculated
>> > several AGGREGATE functions up from my raw data.
>> >
>> > I invoke my macro with :
>> >
>> > !varlst varnam= v1 v2 .
>> >
>> > and it is defined as
>> >
>> > *just a snippet of the syntax.
>> > DEFINE !varlst (varnam=!CMDEND)
>> > !DO !vname !IN (!varnam)
>> > GET FILE= 'c:file\file\file.sav'.
>> > COMPUTE X1 = !vname.
>> > * snip snip.
>> >
>> >
>> > Everything is functioning properly, but I am trying to include the
>> > variable name (e.g. v1) in the reports generated by my macro so that I
>> > can easily distinguish amongst them.  I have tried creating a string
>> > variable with the value !vname and was not able to get this to work.
>> > Additionally, I have tried to use the STRING subcommand in REPORT, but
>> > still was not able to get variable name to print out in each
>> iterations.
>> >
>> > I am on a machine w/o SPSS right now, so I can't check to see exactly
>> > which error message I get, but if I remember correctly, it is
>> related to
>> >
>> > variable type.
>> >
>> > I should note that everything else is functioning 100% correctly, the
>> > operations are performed on the correct variables, it is just being
>> able
>> > to include !vname as a string.
>> >
>> > Thanks for you help
>> >
>> > Jonathan Olmsted
>> >
>>
>>