passing a variable value as function argument

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

passing a variable value as function argument

Norberto Hernandez
Hi everobody. I have a set of 90 variables Var1 to Var90, and I want to set the variable label as follow:

Var1 'Variable 1'
Var2 'Variable 2'
.
.
.
Var90 'Variable 90'

My current syntax is:

LOOP #i=1 TO 90.
   VARIABLE LABELS CONCAT('valp',#i) CONCAT('"Valencia reactivo  "',#i).
END LOOP.

But the system shows me the error "missespecified variable name at VARIABLE LABELS command"

So, I tried to assign the value name with a COMPUTE and pass the variable values as argument for the function VARIABLE LABELS as follow:

  COMPUTE varname =Concat('Var', #i).
  COMPUTE varlabel = Concat('Variable ' #i).
  VARIABLE LABELS varname varlabel.

But the system Error "Character argument necessary for the specified function was not suministered". I think something about passing variable values as arguments is missing, but I'm not sure. I hope you can guide me.

Regards
Norberto Hernández
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: passing a variable value as function argument

David Marso
Administrator

Look up DEFINE !ENDDEFINE and within that section !DO !DOEND and !CONCAT.

Norberto Hernandez wrote
Hi everobody. I have a set of 90 variables Var1 to Var90, and I want to set
the variable label as follow:

Var1 'Variable 1'
Var2 'Variable 2'
.
.
.
Var90 'Variable 90'

My current syntax is:

LOOP #i=1 TO 90.
   VARIABLE LABELS CONCAT('valp',#i) CONCAT('"Valencia reactivo  "',#i).
END LOOP.

But the system shows me the error "missespecified variable name at VARIABLE
LABELS command"

So, I tried to assign the value name with a COMPUTE and pass the variable
values as argument for the function VARIABLE LABELS as follow:

  COMPUTE varname =Concat('Var', #i).
  COMPUTE varlabel = Concat('Variable ' #i).
  VARIABLE LABELS varname varlabel.

But the system Error "Character argument necessary for the specified
function was not suministered". I think something about passing variable
values as arguments is missing, but I'm not sure. I hope you can guide me.

Regards
Norberto Hernández

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: passing a variable value as function argument

Jon K Peck
Or do it with a tiny Python program.

begin program.
import spss
for i in range(1, 91):
    spss.Submit("""VARIABLE LABEL valp%(i)s 'Valencia reactivo %(i)s'.""" % locals())
end program.

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        David Marso <[hidden email]>
To:        [hidden email]
Date:        09/05/2014 05:14 PM
Subject:        Re: [SPSSX-L] passing a variable value as function argument
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Look up DEFINE !ENDDEFINE and within that section !DO !DOEND and !CONCAT.


Norberto Hernandez wrote
> Hi everobody. I have a set of 90 variables Var1 to Var90, and I want to
> set
> the variable label as follow:
>
> Var1 'Variable 1'
> Var2 'Variable 2'
> .
> .
> .
> Var90 'Variable 90'
>
> My current syntax is:
>
> LOOP #i=1 TO 90.
>    VARIABLE LABELS CONCAT('valp',#i) CONCAT('"Valencia reactivo  "',#i).
> END LOOP.
>
> But the system shows me the error "missespecified variable name at
> VARIABLE
> LABELS command"
>
> So, I tried to assign the value name with a COMPUTE and pass the variable
> values as argument for the function VARIABLE LABELS as follow:
>
>   COMPUTE varname =Concat('Var', #i).
>   COMPUTE varlabel = Concat('Variable ' #i).
>   VARIABLE LABELS varname varlabel.
>
> But the system Error "Character argument necessary for the specified
> function was not suministered". I think something about passing variable
> values as arguments is missing, but I'm not sure. I hope you can guide me.
>
> Regards
> Norberto Hernández
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/passing-a-variable-value-as-function-argument-tp5727166p5727167.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: passing a variable value as function argument

Norberto Hernandez
David, Jon, thank you very much for your responses. I still don't understand why it's necessary to pass the arguments in a macro way, and whats the rule about it (in what cases use a macro and in what cases pass directly the arguments). Is any reference about SPSS programming that I could look to?

Thank you
Norberto

2014-09-05 20:11 GMT-05:00 Jon K Peck <[hidden email]>:
Or do it with a tiny Python program.

begin program.
import spss
for i in range(1, 91):
    spss.Submit("""VARIABLE LABEL valp%(i)s 'Valencia reactivo %(i)s'.""" % locals())
end program.

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        David Marso <[hidden email]>
To:        [hidden email]
Date:        09/05/2014 05:14 PM
Subject:        Re: [SPSSX-L] passing a variable value as function argument
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Look up DEFINE !ENDDEFINE and within that section !DO !DOEND and !CONCAT.


Norberto Hernandez wrote
> Hi everobody. I have a set of 90 variables Var1 to Var90, and I want to
> set
> the variable label as follow:
>
> Var1 'Variable 1'
> Var2 'Variable 2'
> .
> .
> .
> Var90 'Variable 90'
>
> My current syntax is:
>
> LOOP #i=1 TO 90.
>    VARIABLE LABELS CONCAT('valp',#i) CONCAT('"Valencia reactivo  "',#i).
> END LOOP.
>
> But the system shows me the error "missespecified variable name at
> VARIABLE
> LABELS command"
>
> So, I tried to assign the value name with a COMPUTE and pass the variable
> values as argument for the function VARIABLE LABELS as follow:
>
>   COMPUTE varname =Concat('Var', #i).
>   COMPUTE varlabel = Concat('Variable ' #i).
>   VARIABLE LABELS varname varlabel.
>
> But the system Error "Character argument necessary for the specified
> function was not suministered". I think something about passing variable
> values as arguments is missing, but I'm not sure. I hope you can guide me.
>
> Regards
> Norberto Hernández
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/passing-a-variable-value-as-function-argument-tp5727166p5727167.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD