Syntax to define variable set

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

Syntax to define variable set

Christine-28
Hi I'm sorry if this is an easy question but I am relatively new to syntax.

I am working with SPSS 15. How would I go about using syntax to define a
variable set?

Thanks, Christine

=====================
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
|

SV: Syntax to define variable set

Wilhelm Svensson | Queue Sweden AB
Hi!

I think the answer to your quiz is VECTOR.

Say that you have the variables A1, A2 and A3.

To define those into a vector you can write.

VECTOR V1 = A1 TO A3.

And if you want to loop through those variables e.g.

LOOP #i=1 to 3.
IF V1(#i) = 1 B1 =1.
END LOOP.
Execute.

Normally you don't have to use VECTOR, or define one. In the most statements
e.g. RECODE you can type:

RECODE A1 to A3 (1=1) INTO B1 to B3.
Execute.

Or to solve the same problem solved by the VECTOR here above you can use:

IF ANY(1,A1 to A3) B1 = 1.
Execute.

All the best

Wilhelm Landerholm | +46-735-460000
Queue Sweden AB - A Management Science Company | www.qsweden.com

The information in this e-mail, including any files transmitted with it, is
confidential and may also be legally privileged. It is intended for the
addressee only. Access to this e-mail by anyone else is unauthorised.
Unauthorised recipients are required to maintain confidentiality and must
not disclose, copy, distribute, or retain this e-mail or any part of it. If
you have received this e-mail in error please notify us immediately, destroy
any copies and delete it from your computer system.

-----Ursprungligt meddelande-----
Från: SPSSX(r) Discussion [mailto:[hidden email]] För Christine
Skickat: den 17 oktober 2008 07:09
Till: [hidden email]
Ämne: Syntax to define variable set

Hi I'm sorry if this is an easy question but I am relatively new to syntax.

I am working with SPSS 15. How would I go about using syntax to define a
variable set?

Thanks, Christine

=====================
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: Syntax to define variable set

Carlos Renato (www.estatistico.org)
Dear friend

     You can use a macro for this...

DEFINE my_SubsetVar ()
 Var1
 Var2
...
...
...
 VarN
!ENDDEFINE.

And to make other operations using this subset of variables using a new
macro with
the commands and in the place of variables, you call "my_SubsetVar" for
example.
Use CMDEND parameter for this.

Carlos Renato
Statistician

=====================
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: Syntax to define variable set

Peck, Jon
In reply to this post by Christine-28
Variable sets are only visible in the user interface.  They are not used in syntax, and there is no direct way to set them in syntax.  They only affect what variables appear in dialog boxes and, in new version, in the Data Editor.

However, if you have a sav file that has sets defined, they can be copied to a new file with Data/Copy Data Properties, aka APPLY DICTIONARY.

HTH,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Christine
Sent: Thursday, October 16, 2008 11:09 PM
To: [hidden email]
Subject: [SPSSX-L] Syntax to define variable set

Hi I'm sorry if this is an easy question but I am relatively new to syntax.

I am working with SPSS 15. How would I go about using syntax to define a
variable set?

Thanks, Christine

=====================
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: Syntax to define variable set

Art Kendall
Jon:
Is there a Python way to to paste the list of variables in a set into a
syntax window?
How about a new command to paste a list for the set into syntax?

Suggestion for a future version of SPSS. It would be very helpful to
develop a way to have the editor paste a list for the set or better to
enhance syntax to recognize the name of a set.
frequencies setofvars= set1...

List members:
A  trick I first used in 1972  is to use snippets of syntax that contain
the list of variables. [Those were the days of 10 cps teletypes but
powerful text editing.]
Once you develop the list, save that piece of syntax. Sometimes on a
project  I have  a file with  just lists of variables for sets. This is
very useful when using an instrument that has several scales.
I then cut-and-paste  the list into a command.

Now that there is a GUI, this is a workaround that I use to get syntax
containing the list of variables in a set.
click define variable sets. then drag variable names.
click use sets.
click analysis.
click frequencies.
use shift down arrow to highlight the list.
drag  the list into the right hand box.
click paste.
now there is a pasted frequencies command that has the syntax that can
be cut down to what you need.

It is often useful to do
match files file=* /keep [paste the list here] all.
then you can use the TO specification on the variable list specification
on subsequent procedures.

HTH

Art Kendall
Social Research Consultants



Peck, Jon wrote:

> Variable sets are only visible in the user interface.  They are not used in syntax, and there is no direct way to set them in syntax.  They only affect what variables appear in dialog boxes and, in new version, in the Data Editor.
>
> However, if you have a sav file that has sets defined, they can be copied to a new file with Data/Copy Data Properties, aka APPLY DICTIONARY.
>
> HTH,
> Jon Peck
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Christine
> Sent: Thursday, October 16, 2008 11:09 PM
> To: [hidden email]
> Subject: [SPSSX-L] Syntax to define variable set
>
> Hi I'm sorry if this is an easy question but I am relatively new to syntax.
>
> I am working with SPSS 15. How would I go about using syntax to define a
> variable set?
>
> Thanks, Christine
>
> =====================
> 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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Syntax to define variable set

Peck, Jon
It is possible using programmability to retrieve the definitions of the variable sets, although their in-use status is not available.  It is also possible to deposit the variables in one or more variable sets into a new syntax window.  (You can also replace the contents of an existing window).  Since one of these is a programmability api and one is a scripting api, using these together would be most easily done with version 17.  With any version, it would be easy to write the expanded definition of a set to a file or, better, to create a macro that defines that variable list for use in other syntax.

I could make this into an extension command (requiring 16 or 17) as well as a Python function.

Comments?

Regards,
Jon Peck

-----Original Message-----
From: Art Kendall [mailto:[hidden email]]
Sent: Friday, October 17, 2008 8:19 AM
To: Peck, Jon
Cc: [hidden email]
Subject: Re: Syntax to define variable set

Jon:
Is there a Python way to to paste the list of variables in a set into a
syntax window?
How about a new command to paste a list for the set into syntax?

Suggestion for a future version of SPSS. It would be very helpful to
develop a way to have the editor paste a list for the set or better to
enhance syntax to recognize the name of a set.
frequencies setofvars= set1...
[>>>Peck, Jon] It's called macro.

=====================
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: Syntax to define variable set

Art Kendall
Thank you for your quick response.

I personally to not have a short-term need for this.  I just thought up
the idea in response to the OP. Since it seems to me (YMMV) that the
availability of Python makes macros somewhat obsolete.  I would lean
toward first putting the expanded lists into a syntax file.  From my
work habits, I would lean toward a new separate syntax file that could
be cannibalized as needed.

With the expanded set in a syntax window, beyond fundamentals of syntax,
a user would only need to know how to copy-and-paste. To use a macro,
wouldn't  a user have to know something about macros other than pasting
or INSERTing the macro into the main syntax?
It wouldn't  just be
frequencies variables= !set1 ...
would it?

I expect to receive version 17 soon, but there will probably be a need
for a version 16 function for some users.


Art Kendall
Social Research Consultants

Peck, Jon wrote:

> It is possible using programmability to retrieve the definitions of the variable sets, although their in-use status is not available.  It is also possible to deposit the variables in one or more variable sets into a new syntax window.  (You can also replace the contents of an existing window).  Since one of these is a programmability api and one is a scripting api, using these together would be most easily done with version 17.  With any version, it would be easy to write the expanded definition of a set to a file or, better, to create a macro that defines that variable list for use in other syntax.
>
> I could make this into an extension command (requiring 16 or 17) as well as a Python function.
>
> Comments?
>
> Regards,
> Jon Peck
>
> -----Original Message-----
> From: Art Kendall [mailto:[hidden email]]
> Sent: Friday, October 17, 2008 8:19 AM
> To: Peck, Jon
> Cc: [hidden email]
> Subject: Re: Syntax to define variable set
>
> Jon:
> Is there a Python way to to paste the list of variables in a set into a
> syntax window?
> How about a new command to paste a list for the set into syntax?
>
> Suggestion for a future version of SPSS. It would be very helpful to
> develop a way to have the editor paste a list for the set or better to
> enhance syntax to recognize the name of a set.
> frequencies setofvars= set1...
> [>>>Peck, Jon] It's called macro.
>
> =====================
> 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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Syntax to define variable set

Peck, Jon
-----Original Message-----
From: Art Kendall [mailto:[hidden email]]
Sent: Friday, October 17, 2008 10:09 AM
To: Peck, Jon
Cc: [hidden email]
Subject: Re: Syntax to define variable set


With the expanded set in a syntax window, beyond fundamentals of syntax,
a user would only need to know how to copy-and-paste. To use a macro,
wouldn't  a user have to know something about macros other than pasting
or INSERTing the macro into the main syntax?
It wouldn't  just be
frequencies variables= !set1 ...
would it?
[>>>Peck, Jon] Yes it would.

Something like
MACROSET SETS=list-of-setnames MACRONAME=!art.
DESC !art.

=====================
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: Syntax to define variable set

Art Kendall
I sometimes confuse the kinds of macros in different software. That
would certainly be easy to work with.

Art

Peck, Jon wrote:

> -----Original Message-----
> From: Art Kendall [mailto:[hidden email]]
> Sent: Friday, October 17, 2008 10:09 AM
> To: Peck, Jon
> Cc: [hidden email]
> Subject: Re: Syntax to define variable set
>
>
> With the expanded set in a syntax window, beyond fundamentals of syntax,
> a user would only need to know how to copy-and-paste. To use a macro,
> wouldn't  a user have to know something about macros other than pasting
> or INSERTing the macro into the main syntax?
> It wouldn't  just be
> frequencies variables= !set1 ...
> would it?
> [>>>Peck, Jon] Yes it would.
>
> Something like
> MACROSET SETS=list-of-setnames MACRONAME=!art.
> DESC !art.
>
> =====================
> 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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Syntax to define variable set

Christine-28
In reply to this post by Peck, Jon
Thanks for all your replies. The macro sounds good however may I ask for
clarification - which suggestion will provide me with the ability to use the
same code on a number of different files?
I can't see exactly from the replies whether there is syntax suggested or
whether the macro is the best solution. I'm fine to write a macro however
I'm not sure if I can save it outside the working file.

Thanks,
Christine


2008/10/18 Peck, Jon <[hidden email]>

> -----Original Message-----
> From: Art Kendall [mailto:[hidden email]]
> Sent: Friday, October 17, 2008 10:09 AM
> To: Peck, Jon
> Cc: [hidden email]
> Subject: Re: Syntax to define variable set
>
>
> With the expanded set in a syntax window, beyond fundamentals of syntax,
> a user would only need to know how to copy-and-paste. To use a macro,
> wouldn't  a user have to know something about macros other than pasting
> or INSERTing the macro into the main syntax?
> It wouldn't  just be
> frequencies variables= !set1 ...
> would it?
> [>>>Peck, Jon] Yes it would.
>
> Something like
> MACROSET SETS=list-of-setnames MACRONAME=!art.
> DESC !art.
>
> =====================
> 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: Syntax to define variable set

Peck, Jon
What I have written will define a macro directly based on one or more sets in the current dataset.  But it will also optionally write the list of variables to a file that you could copy from.  Maybe I'll set it up so that writes the syntax for the macro definition.  Then you could just include/insert that file.

Or, since Copy Data Properties can copy set definitions, you could use that (or APPLY DICTIONARY) to copy the set definition and then run this extension command again in the new dataset.

To use the extension command version requires SPSS 16 or 17.  To use the Python function version requires SPSS 14 or later.  In both cases you have to install the programmability plug-in and Python.


HTH,
Jon Peck
-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Christine
Sent: Friday, October 17, 2008 4:58 PM
To: [hidden email]
Subject: Re: [SPSSX-L] Syntax to define variable set

Thanks for all your replies. The macro sounds good however may I ask for
clarification - which suggestion will provide me with the ability to use the
same code on a number of different files?
I can't see exactly from the replies whether there is syntax suggested or
whether the macro is the best solution. I'm fine to write a macro however
I'm not sure if I can save it outside the working file.

Thanks,
Christine


2008/10/18 Peck, Jon <[hidden email]>

> -----Original Message-----
> From: Art Kendall [mailto:[hidden email]]
> Sent: Friday, October 17, 2008 10:09 AM
> To: Peck, Jon
> Cc: [hidden email]
> Subject: Re: Syntax to define variable set
>
>
> With the expanded set in a syntax window, beyond fundamentals of syntax,
> a user would only need to know how to copy-and-paste. To use a macro,
> wouldn't  a user have to know something about macros other than pasting
> or INSERTing the macro into the main syntax?
> It wouldn't  just be
> frequencies variables= !set1 ...
> would it?
> [>>>Peck, Jon] Yes it would.
>
> Something like
> MACROSET SETS=list-of-setnames MACRONAME=!art.
> DESC !art.
>
> =====================
> 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