AW: Is there an easy way to lable the values of one variable with the values of an other?

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

AW: Is there an easy way to lable the values of one variable with the values of an other?

Falcato Luis
Hi,

Because there are many many codes and this would need a very long val lab statement and a lot of writing...I' looking for a automated way to do it.
-----Ursprüngliche Nachricht-----
Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Helmut Vorkauf
Gesendet: Freitag, 13. Juni 2008 15:10
An: Falcato Luis
Betreff: Re: Is there an easy way to lable the values of one variable with the values of an other?

why not just
VALUE LABELS VAR2 'F11.2'  'Psychische und Verhaltensstörungen durch Opioide: Abhängigkeitssyndrom' 'F14.1' 'Psychische und Verhaltensstörungen durch Kokain: Schädlicher Gebrauch'



On Fri, Jun 13, 2008 at 2:34 PM, Falcato Luis <[hidden email]> wrote:
Dear SPSSers

Is there an easy way to label the values of one variable with the values of an other?

Example:
The data file contains 3 variables. I would like to have the values of Var2 labeled with the strings stored in Var3.

Var1            Var2            Var3
CaseID  ICD-Code        verbatim diagnose
180             F11.2   Psychische und Verhaltensstörungen durch Opioide: Abhängigkeitssyndrom
2965            F11.2   Psychische und Verhaltensstörungen durch Opioide: Abhängigkeitssyndrom
2880            F14.1   Psychische und Verhaltensstörungen durch Kokain: Schädlicher Gebrauch
...



Many thanks for your sugestions.

Regards Luis

Luis Manuel Falcato, lic. phil.
Leiter Evaluation + Forschung
ARUD Zürich
Sihlhallenstrasse 30
CH-8026 Zürich
[hidden email]<mailto:[hidden email]>
www.arud-zh.ch<http://www.arud-zh.ch>
www.gain-zh.ch<http://www.gain-zh.ch>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email]<mailto:[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



--
Helmut Vorkauf
e-mail [hidden email]
tel ++41-(0)31-332 21 64
mobile ++41-(0)79-622 88 03
fax ++41-(0)31-560 45 31

====================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: Is there an easy way to lable the values of one variable with the values of an other?

ViAnn Beadle
Why not just use Var3 in your analysis as a string variable? What do you
intend to do with this variable?

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Falcato Luis
Sent: Friday, June 13, 2008 7:17 AM
To: [hidden email]
Subject: AW: Is there an easy way to lable the values of one variable with
the values of an other?

Hi,

Because there are many many codes and this would need a very long val lab
statement and a lot of writing...I' looking for a automated way to do it.
-----Ursprüngliche Nachricht-----
Von: [hidden email] [mailto:[hidden email]] Im Auftrag
von Helmut Vorkauf
Gesendet: Freitag, 13. Juni 2008 15:10
An: Falcato Luis
Betreff: Re: Is there an easy way to lable the values of one variable with
the values of an other?

why not just
VALUE LABELS VAR2 'F11.2'  'Psychische und Verhaltensstörungen durch
Opioide: Abhängigkeitssyndrom' 'F14.1' 'Psychische und Verhaltensstörungen
durch Kokain: Schädlicher Gebrauch'



On Fri, Jun 13, 2008 at 2:34 PM, Falcato Luis <[hidden email]> wrote:
Dear SPSSers

Is there an easy way to label the values of one variable with the values of
an other?

Example:
The data file contains 3 variables. I would like to have the values of Var2
labeled with the strings stored in Var3.

Var1            Var2            Var3
CaseID  ICD-Code        verbatim diagnose
180             F11.2   Psychische und Verhaltensstörungen durch Opioide:
Abhängigkeitssyndrom
2965            F11.2   Psychische und Verhaltensstörungen durch Opioide:
Abhängigkeitssyndrom
2880            F14.1   Psychische und Verhaltensstörungen durch Kokain:
Schädlicher Gebrauch
...



Many thanks for your sugestions.

Regards Luis

Luis Manuel Falcato, lic. phil.
Leiter Evaluation + Forschung
ARUD Zürich
Sihlhallenstrasse 30
CH-8026 Zürich
[hidden email]<mailto:[hidden email]>
www.arud-zh.ch<http://www.arud-zh.ch>
www.gain-zh.ch<http://www.gain-zh.ch>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email]<mailto:[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



--
Helmut Vorkauf
e-mail [hidden email]
tel ++41-(0)31-332 21 64
mobile ++41-(0)79-622 88 03
fax ++41-(0)31-560 45 31

=======
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: Is there an easy way to lable the values of one variable with the values of an other?

Kornbrot, Diana
Try going to variable view
Click on labels for already coded variable, copy and then paste to new
variable
Think I got some verion of this to work at some stage
diana


On 13/6/08 14:31, "ViAnn Beadle" <[hidden email]> wrote:

> Why not just use Var3 in your analysis as a string variable? What do you
> intend to do with this variable?
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> Falcato Luis
> Sent: Friday, June 13, 2008 7:17 AM
> To: [hidden email]
> Subject: AW: Is there an easy way to lable the values of one variable with
> the values of an other?
>
> Hi,
>
> Because there are many many codes and this would need a very long val lab
> statement and a lot of writing...I' looking for a automated way to do it.
> -----Ursprüngliche Nachricht-----
> Von: [hidden email] [mailto:[hidden email]] Im Auftrag
> von Helmut Vorkauf
> Gesendet: Freitag, 13. Juni 2008 15:10
> An: Falcato Luis
> Betreff: Re: Is there an easy way to lable the values of one variable with
> the values of an other?
>
> why not just
> VALUE LABELS VAR2 'F11.2'  'Psychische und Verhaltensstörungen durch
> Opioide: Abhängigkeitssyndrom' 'F14.1' 'Psychische und Verhaltensstörungen
> durch Kokain: Schädlicher Gebrauch'
>
>
>
> On Fri, Jun 13, 2008 at 2:34 PM, Falcato Luis <[hidden email]> wrote:
> Dear SPSSers
>
> Is there an easy way to label the values of one variable with the values of
> an other?
>
> Example:
> The data file contains 3 variables. I would like to have the values of Var2
> labeled with the strings stored in Var3.
>
> Var1            Var2            Var3
> CaseID  ICD-Code        verbatim diagnose
> 180             F11.2   Psychische und Verhaltensstörungen durch Opioide:
> Abhängigkeitssyndrom
> 2965            F11.2   Psychische und Verhaltensstörungen durch Opioide:
> Abhängigkeitssyndrom
> 2880            F14.1   Psychische und Verhaltensstörungen durch Kokain:
> Schädlicher Gebrauch
> ...
>
>
>
> Many thanks for your sugestions.
>
> Regards Luis
>
> Luis Manuel Falcato, lic. phil.
> Leiter Evaluation + Forschung
> ARUD Zürich
> Sihlhallenstrasse 30
> CH-8026 Zürich
> [hidden email]<mailto:[hidden email]>
> www.arud-zh.ch<http://www.arud-zh.ch>
> www.gain-zh.ch<http://www.gain-zh.ch>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email]<mailto:[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
>
>
>
> --
> Helmut Vorkauf
> e-mail [hidden email]
> tel ++41-(0)31-332 21 64
> mobile ++41-(0)79-622 88 03
> fax ++41-(0)31-560 45 31
>
> =======
> 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


Professor Diana Kornbrot
 School of Psychology
 University of Hertfordshire
 College Lane, Hatfield, Hertfordshire AL10 9AB, UK

 email:  [hidden email]
 web:    http://web.mac.com/kornbrot/iweb/KornbrotHome.html
 voice:   +44 (0) 170 728 4626
 fax:      +44 (0) 170 728 5073
Home
 19 Elmhurst Avenue
 London N2 0LT, UK
   
    voice:   +44 (0) 208 883  3657
    mobile: +44 (0) 796 890 2102
    fax:      +44 (0) 870 706 4997

====================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: Is there an easy way to lable the values of one variable with the values of an other?

Daniel Robertson
In reply to this post by ViAnn Beadle
I can think of a few reasons why the OPs request would be useful; this
is a problem I've been thinking about as well but haven't found a
solution to. To be clear, I understood the OPs request as finding an
/automated/ way to assign value labels to one variable based on the
associated values of another variable, assuming there is a one-to-one
mapping between the values of the two variables.

Let me offer another example. Our newly implemented campus data system
represents many types of categorical information by using two fields, a
short code and a descriptor, and there is always a one-to-one mapping
between codes and descriptors. Here's an example using Financial Aid Type:

  FA_CODE     FA_TYPE_DESCR
  "2"         "Loan/Work Replacing Grant"
  "L"         "Loan"
  "W"         "Work/Study"

The FA_CODE field is short and more convenient to use in coding -- e.g.,
typing "if(FA_TYPE EQ '2')" is for me less prone to error than typing
"if(FA_TYPE_DESCR = 'Loan/Work Replacing Grant')" -- but the Long
Descriptor field is, well, much more descriptive and would be useful in
tables and reports.

For parsimony's sake, it would be nice to retain the CODE variable but
apply the associated values in the DESCRIPTOR variable as value labels
to the CODE variable. New codes with their associated descriptions can
be added to the source database at any time, which is why I am
interested in deriving the value labels from the data anew each time I
extract a datafile. AUTORECODE is a less-attractive option because I
(and I think the OP as well) would like to retain the original code used
in the source file.

I have a vague idea that this could be done by generating a table of
code-descriptor pairs using a CTABLE command, access the table with OMS,
and write a python macro to assign the descriptors as value labels to
their associated codes. But I haven't gotten very far and am not sure
this is even a reasonable approach.

Anyone else tried this or have any ideas?

Dan R.



ViAnn Beadle wrote:

> Why not just use Var3 in your analysis as a string variable? What do you
> intend to do with this variable?
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> Falcato Luis
> Sent: Friday, June 13, 2008 7:17 AM
> To: [hidden email]
> Subject: AW: Is there an easy way to lable the values of one variable with
> the values of an other?
>
> Hi,
>
> Because there are many many codes and this would need a very long val lab
> statement and a lot of writing...I' looking for a automated way to do it.
> -----Ursprüngliche Nachricht-----
> Von: [hidden email] [mailto:[hidden email]] Im Auftrag
> von Helmut Vorkauf
> Gesendet: Freitag, 13. Juni 2008 15:10
> An: Falcato Luis
> Betreff: Re: Is there an easy way to lable the values of one variable with
> the values of an other?
>
> why not just
> VALUE LABELS VAR2 'F11.2'  'Psychische und Verhaltensstörungen durch
> Opioide: Abhängigkeitssyndrom' 'F14.1' 'Psychische und Verhaltensstörungen
> durch Kokain: Schädlicher Gebrauch'
>
>
>
> On Fri, Jun 13, 2008 at 2:34 PM, Falcato Luis <[hidden email]> wrote:
> Dear SPSSers
>
> Is there an easy way to label the values of one variable with the values of
> an other?
>
> Example:
> The data file contains 3 variables. I would like to have the values of Var2
> labeled with the strings stored in Var3.
>
> Var1            Var2            Var3
> CaseID  ICD-Code        verbatim diagnose
> 180             F11.2   Psychische und Verhaltensstörungen durch Opioide:
> Abhängigkeitssyndrom
> 2965            F11.2   Psychische und Verhaltensstörungen durch Opioide:
> Abhängigkeitssyndrom
> 2880            F14.1   Psychische und Verhaltensstörungen durch Kokain:
> Schädlicher Gebrauch
> ...
>
>
>
> Many thanks for your sugestions.
>
> Regards Luis
>
> Luis Manuel Falcato, lic. phil.
> Leiter Evaluation + Forschung
> ARUD Zürich
> Sihlhallenstrasse 30
> CH-8026 Zürich
> [hidden email]<mailto:[hidden email]>
> www.arud-zh.ch<http://www.arud-zh.ch>
> www.gain-zh.ch<http://www.gain-zh.ch>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email]<mailto:[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
>
>
>
> --
> Helmut Vorkauf
> e-mail [hidden email]
> tel ++41-(0)31-332 21 64
> mobile ++41-(0)79-622 88 03
> fax ++41-(0)31-560 45 31
>
>
>

--
Daniel Robertson
Senior Research and Planning Associate
Institutional Research and Planning
Cornell University / irp.cornell.edu

=====================
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: Is there an easy way to lable the values of one variable with the values of an other?

Oliver, Richard
In reply to this post by Kornbrot, Diana
Some of my colleagues will scold me for suggesting this somewhat old-fashioned solution:

data list list /numvar (f1) stringvar (a4).
begin data
1 abc
2 def
3 ghi
4 jkl
4 jkl
2 def
end data.
dataset name original.
dataset declare aggfile.
aggregate outfile=aggfile mode=replace
  /break=numvar /stringvar=first(stringvar).
write outfile='c:\temp\temp.sps'
  /'add value labels numvar'
  /numvar " '" stringvar "'.".
dataset activate original.
insert file='c:\temp\temp.sps'.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of kornbrot
Sent: Friday, June 13, 2008 8:54 AM
To: [hidden email]
Subject: Re: Is there an easy way to lable the values of one variable with the values of an other?

Try going to variable view
Click on labels for already coded variable, copy and then paste to new
variable
Think I got some verion of this to work at some stage
diana


On 13/6/08 14:31, "ViAnn Beadle" <[hidden email]> wrote:

> Why not just use Var3 in your analysis as a string variable? What do you
> intend to do with this variable?
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> Falcato Luis
> Sent: Friday, June 13, 2008 7:17 AM
> To: [hidden email]
> Subject: AW: Is there an easy way to lable the values of one variable with
> the values of an other?
>
> Hi,
>
> Because there are many many codes and this would need a very long val lab
> statement and a lot of writing...I' looking for a automated way to do it.
> -----Ursprüngliche Nachricht-----
> Von: [hidden email] [mailto:[hidden email]] Im Auftrag
> von Helmut Vorkauf
> Gesendet: Freitag, 13. Juni 2008 15:10
> An: Falcato Luis
> Betreff: Re: Is there an easy way to lable the values of one variable with
> the values of an other?
>
> why not just
> VALUE LABELS VAR2 'F11.2'  'Psychische und Verhaltensstörungen durch
> Opioide: Abhängigkeitssyndrom' 'F14.1' 'Psychische und Verhaltensstörungen
> durch Kokain: Schädlicher Gebrauch'
>
>
>
> On Fri, Jun 13, 2008 at 2:34 PM, Falcato Luis <[hidden email]> wrote:
> Dear SPSSers
>
> Is there an easy way to label the values of one variable with the values of
> an other?
>
> Example:
> The data file contains 3 variables. I would like to have the values of Var2
> labeled with the strings stored in Var3.
>
> Var1            Var2            Var3
> CaseID  ICD-Code        verbatim diagnose
> 180             F11.2   Psychische und Verhaltensstörungen durch Opioide:
> Abhängigkeitssyndrom
> 2965            F11.2   Psychische und Verhaltensstörungen durch Opioide:
> Abhängigkeitssyndrom
> 2880            F14.1   Psychische und Verhaltensstörungen durch Kokain:
> Schädlicher Gebrauch
> ...
>
>
>
> Many thanks for your sugestions.
>
> Regards Luis
>
> Luis Manuel Falcato, lic. phil.
> Leiter Evaluation + Forschung
> ARUD Zürich
> Sihlhallenstrasse 30
> CH-8026 Zürich
> [hidden email]<mailto:[hidden email]>
> www.arud-zh.ch<http://www.arud-zh.ch>
> www.gain-zh.ch<http://www.gain-zh.ch>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email]<mailto:[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
>
>
>
> --
> Helmut Vorkauf
> e-mail [hidden email]
> tel ++41-(0)31-332 21 64
> mobile ++41-(0)79-622 88 03
> fax ++41-(0)31-560 45 31
>
> =======
> 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


Professor Diana Kornbrot
 School of Psychology
 University of Hertfordshire
 College Lane, Hatfield, Hertfordshire AL10 9AB, UK

 email:  [hidden email]
 web:    http://web.mac.com/kornbrot/iweb/KornbrotHome.html
 voice:   +44 (0) 170 728 4626
 fax:      +44 (0) 170 728 5073
Home
 19 Elmhurst Avenue
 London N2 0LT, UK

    voice:   +44 (0) 208 883  3657
    mobile: +44 (0) 796 890 2102
    fax:      +44 (0) 870 706 4997

=======
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: Is there an easy way to lable the values of one variable with the values of an other?

Daniel Robertson
That works! Brilliant!

Oliver, Richard wrote:

> Some of my colleagues will scold me for suggesting this somewhat old-fashioned solution:
>
> data list list /numvar (f1) stringvar (a4).
> begin data
> 1 abc
> 2 def
> 3 ghi
> 4 jkl
> 4 jkl
> 2 def
> end data.
> dataset name original.
> dataset declare aggfile.
> aggregate outfile=aggfile mode=replace
>   /break=numvar /stringvar=first(stringvar).
> write outfile='c:\temp\temp.sps'
>   /'add value labels numvar'
>   /numvar " '" stringvar "'.".
> dataset activate original.
> insert file='c:\temp\temp.sps'.
>
>

--
Daniel Robertson
Senior Research and Planning Associate
Institutional Research and Planning
Cornell University / irp.cornell.edu

=====================
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: Is there an easy way to lable the values of one variable with the values of an other?

Peck, Jon
Since Rick offered the possibility of a scolding (and I know who he had in mind), I'll take him up on that, albeit mildly.
His solution does work in many cases, but it has a few problems as a general solution.
First, you have to wire a location in the code (here c:\temp).
Second if either value contains single quotes (numvar could actually be a string), the generated syntax will be invalid.
Third, if there are any conflicts - two different strings for the same value of the target variable, you won’t find out about it.

Since I greatly dislike solutions that write syntax to a file and then read it back, I have added a function, genValueLabels, to spssaux2.py, which is downloadable from SPSS Developer Central (www.spss.com/devcentral), that does this task via programmability.  For example,

BEGIN PROGRAM.
import spssaux2
if not spssaux2.genValueLabels('numvar', 'stringvar'):
  print "At least one label conflicts"
END PROGRAM.

Regards,
Jon Peck


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Daniel Robertson
Sent: Friday, June 13, 2008 8:36 AM
To: [hidden email]
Subject: Re: [SPSSX-L] Is there an easy way to lable the values of one variable with the values of an other?

That works! Brilliant!

Oliver, Richard wrote:

> Some of my colleagues will scold me for suggesting this somewhat old-fashioned solution:
>
> data list list /numvar (f1) stringvar (a4).
> begin data
> 1 abc
> 2 def
> 3 ghi
> 4 jkl
> 4 jkl
> 2 def
> end data.
> dataset name original.
> dataset declare aggfile.
> aggregate outfile=aggfile mode=replace
>   /break=numvar /stringvar=first(stringvar).
> write outfile='c:\temp\temp.sps'
>   /'add value labels numvar'
>   /numvar " '" stringvar "'.".
> dataset activate original.
> insert file='c:\temp\temp.sps'.
>
>

--
Daniel Robertson
Senior Research and Planning Associate
Institutional Research and Planning
Cornell University / irp.cornell.edu

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

sample and freq wt

Manmit Shrimali-2
Team:

I have to apply apply sample and frequency weigt when generating mean of x variable. Below are the variables
id #_family_memb_houseld #of_coke_consumed drink_alcohol
1 3 40 yes
2 8 10 no
3 5 35 yes

I have to first apply sample weigt. of population by region and then when taking mean of number of coke consumed i want to apply weig. of # of family members i.e. weigtd mean. I know that spss cannot apply two wt variable together - do anyone have some work around? i heard something bout rim weigt but was not able to find much on google.

The second problem is even more challenging - how to apply these weigt. when taking frequency of the variable "drink_alchol" which 0/1 (yes/no) variable.

Any advice is greatly appreciated. I have spss 14 base table and ctable.

MS

=====================
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: Is there an easy way to lable the values of one variable with the values of an other?

Daniel Robertson
In reply to this post by Peck, Jon
Hmm, it runs fine in 16 but here's what I get when I try it with 15:

Traceback (most recent call last):
  File "<string>", line 2, in ?
  File "C:\Python24\lib\site-packages\spssaux2.py", line 836, in
genValueLabels
    val = u(case[0])
  File "C:\Python24\lib\site-packages\spssaux.py", line 1379, in u
    if spss.PyInvokeSpss.IsUTF8mode():
AttributeError: 'module' object has no attribute 'IsUTF8mode'

It looks like spssaux.u() references PyInvokeSpss.IsUTF8mode().
PyInvokeSpss is in bit code, but I can see references to IsUFT8mode() in
the 16 version of spss.py but not in the 15 version.

Peck, Jon wrote:

> I didn't test this with 15, but it should work with it.  I deliberately avoided some new SPSS 16 apis that would have simplified this a bit.  All you need is a new download of spssaux2.py.  If your spssaux.py module is old, you might need a newer copy of that, too, but it should be compatible with 15.
>
> -----Original Message-----
> From: Daniel Robertson [mailto:[hidden email]]
> Sent: Monday, June 16, 2008 8:51 AM
> To: Peck, Jon
> Subject: Re: [SPSSX-L] Is there an easy way to lable the values of one variable with the values of an other?
>
> Jon, this is clever and runs great -- I've got a lot to learn :)
>
> It looks like that this works only with v.16 of the plugin -- is this
> correct?
>
> Thanks,
> Dan R.
>
> Peck, Jon wrote:
>
>> Since Rick offered the possibility of a scolding (and I know who he had in mind), I'll take him up on that, albeit mildly.
>> His solution does work in many cases, but it has a few problems as a general solution.
>> First, you have to wire a location in the code (here c:\temp).
>> Second if either value contains single quotes (numvar could actually be a string), the generated syntax will be invalid.
>> Third, if there are any conflicts - two different strings for the same value of the target variable, you won’t find out about it.
>>
>> Since I greatly dislike solutions that write syntax to a file and then read it back, I have added a function, genValueLabels, to spssaux2.py, which is downloadable from SPSS Developer Central (www.spss.com/devcentral), that does this task via programmability.  For example,
>>
>> BEGIN PROGRAM.
>> import spssaux2
>> if not spssaux2.genValueLabels('numvar', 'stringvar'):
>>   print "At least one label conflicts"
>> END PROGRAM.
>>
>> Regards,
>> Jon Peck
>>
>>
>> -----Original Message-----
>> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Daniel Robertson
>> Sent: Friday, June 13, 2008 8:36 AM
>> To: [hidden email]
>> Subject: Re: [SPSSX-L] Is there an easy way to lable the values of one variable with the values of an other?
>>
>> That works! Brilliant!
>>
>> Oliver, Richard wrote:
>>
>>
>>> Some of my colleagues will scold me for suggesting this somewhat old-fashioned solution:
>>>
>>> data list list /numvar (f1) stringvar (a4).
>>> begin data
>>> 1 abc
>>> 2 def
>>> 3 ghi
>>> 4 jkl
>>> 4 jkl
>>> 2 def
>>> end data.
>>> dataset name original.
>>> dataset declare aggfile.
>>> aggregate outfile=aggfile mode=replace
>>>   /break=numvar /stringvar=first(stringvar).
>>> write outfile='c:\temp\temp.sps'
>>>   /'add value labels numvar'
>>>   /numvar " '" stringvar "'.".
>>> dataset activate original.
>>> insert file='c:\temp\temp.sps'.
>>>
>>>
>>>
>>>
>> --
>> Daniel Robertson
>> Senior Research and Planning Associate
>> Institutional Research and Planning
>> Cornell University / irp.cornell.edu
>>
>> =====================
>> 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
>>
>>
>>
>
>

--
Daniel Robertson
Senior Research and Planning Associate
Institutional Research and Planning
Cornell University / irp.cornell.edu

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