Syntax to crop variable labels

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

Syntax to crop variable labels

John F Hall
I am working on a file constructed by someone else.  There are hundreds of variable labels of the following type.  Rather than going through and deleting the brackets and their contents manually, is there any syntax to do it for me?  Otherwise I'll be at it all night.
 
TIA
 
John Hall
 
(614)My assignments don't require using technology
(615)School filters or firewalls block websites I need to use
(616)Software is not good enough
(617)Teachers don't know how to use the technology
(618)Teachers limit our technology use
(619)There are rules against using technology at my school
(620)My school has different computers or software than I am used to
Reply | Threaded
Open this post in threaded view
|

Re: Syntax to crop variable labels

Art Kendall
copy the syntax below into a syntax window.  See if this is what you need. Then try replacing the piece of text in the syntax window between "begin data" and "end data" with the text from the other source.
copy the resulting print info into a new syntax window.

data list fixed /item (1x,f3) itemlabel(1x, a70).
begin data
(614)My assignments don't require using technology
(615)School filters or firewalls block websites I need to use
(616)Software is not good enough
(617)Teachers don't know how to use the technology
(618)Teachers limit our technology use
(619)There are rules against using technology at my school
(620)My school has different computers or software than I am used to
end data.
print  /'     ' item '"' itemlabel '"/'.
execute.

Art Kendall
Social Research Consultants

On 7/5/2010 11:29 AM, John F Hall wrote:
I am working on a file constructed by someone else.  There are hundreds of variable labels of the following type.  Rather than going through and deleting the brackets and their contents manually, is there any syntax to do it for me?  Otherwise I'll be at it all night.
 
TIA
 
John Hall
 
(614)My assignments don't require using technology
(615)School filters or firewalls block websites I need to use
(616)Software is not good enough
(617)Teachers don't know how to use the technology
(618)Teachers limit our technology use
(619)There are rules against using technology at my school
(620)My school has different computers or software than I am used to
===================== 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 crop variable labels

Albert-Jan Roskam
Hi,
 
Something like this might also do what you want:
 
set mprint = on.
get file = 'c:/program files/spss/employee data.sav'.
begin program.
import spss, spssaux
def truncate_labels(var, maxlen):
  vardict = spssaux.VariableDict()
  labels = vardict[var].ValueLabels
  for k, v in labels.iteritems():
    spss.Submit("add value labels %s %s '%s'."  % (var, k, v[0:maxlen] + "..."))
truncate_labels(var = "jobcat", maxlen = 3)
end program.

Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- On Mon, 7/5/10, Art Kendall <[hidden email]> wrote:

From: Art Kendall <[hidden email]>
Subject: Re: [SPSSX-L] Syntax to crop variable labels
To: [hidden email]
Date: Monday, July 5, 2010, 5:51 PM

copy the syntax below into a syntax window.  See if this is what you need. Then try replacing the piece of text in the syntax window between "begin data" and "end data" with the text from the other source.
copy the resulting print info into a new syntax window.

data list fixed /item (1x,f3) itemlabel(1x, a70).
begin data
(614)My assignments don't require using technology
(615)School filters or firewalls block websites I need to use
(616)Software is not good enough
(617)Teachers don't know how to use the technology
(618)Teachers limit our technology use
(619)There are rules against using technology at my school
(620)My school has different computers or software than I am used to
end data.
print  /'     ' item '"' itemlabel '"/'.
execute.

Art Kendall
Social Research Consultants

On 7/5/2010 11:29 AM, John F Hall wrote:
I am working on a file constructed by someone else.  There are hundreds of variable labels of the following type.  Rather than going through and deleting the brackets and their contents manually, is there any syntax to do it for me?  Otherwise I'll be at it all night.
 
TIA
 
John Hall
 
(614)My assignments don't require using technology
(615)School filters or firewalls block websites I need to use
(616)Software is not good enough
(617)Teachers don't know how to use the technology
(618)Teachers limit our technology use
(619)There are rules against using technology at my school
(620)My school has different computers or software than I am used to
===================== 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 crop variable labels

John F Hall
In reply to this post by Art Kendall
Art
 
Thanks for the syntax: this is what I get: 
 

     614 "My assignments don't require using technology                          "/

     615 "School filters or firewalls block websites I need to use               "/

     616 "Software is not good enough                                            "/

     617 "Teachers don't know how to use the technology                          "/

     618 "Teachers limit our technology use                                      "/

     619 "There are rules against using technology at my school                  "/

     620 "My school has different computers or software than I am used to        "/

 

but I don't want the numbers, just the text.  However, if the syntax can be amended to yield

 

     token614 "My assignments don't require using technology                          "/

     token615 "School filters or firewalls block websites I need to use               "/

 

I can then run var labels with the result.  This saves manually amending about 400 labels.

 

John

 

PS  I like my slashes at the beginning of the line (with a preceding space of course) where I can see them.

 

 

----- Original Message -----

Sent: Monday, July 05, 2010 5:51 PM
Subject: Re: Syntax to crop variable labels

copy the syntax below into a syntax window.  See if this is what you need. Then try replacing the piece of text in the syntax window between "begin data" and "end data" with the text from the other source.
copy the resulting print info into a new syntax window.

data list fixed /item (1x,f3) itemlabel(1x, a70).
begin data
(614)My assignments don't require using technology
(615)School filters or firewalls block websites I need to use
(616)Software is not good enough
(617)Teachers don't know how to use the technology
(618)Teachers limit our technology use
(619)There are rules against using technology at my school
(620)My school has different computers or software than I am used to
end data.
print  /'     ' item '"' itemlabel '"/'.
execute.

Art Kendall
Social Research Consultants

On 7/5/2010 11:29 AM, John F Hall wrote:
I am working on a file constructed by someone else.  There are hundreds of variable labels of the following type.  Rather than going through and deleting the brackets and their contents manually, is there any syntax to do it for me?  Otherwise I'll be at it all night.
 
TIA
 
John Hall
 
(614)My assignments don't require using technology
(615)School filters or firewalls block websites I need to use
(616)Software is not good enough
(617)Teachers don't know how to use the technology
(618)Teachers limit our technology use
(619)There are rules against using technology at my school
(620)My school has different computers or software than I am used to
===================== 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 crop variable labels

John F Hall
In reply to this post by Albert-Jan Roskam
Albert-Jan
 
Thanks for this.  Art sent me something that almost works, but I really must go and cut the grass before dinner.  I'll try your syntax out later while Mrs H is watching Coronation St, East Enders, Coronation St
 
John
----- Original Message -----
Sent: Monday, July 05, 2010 6:13 PM
Subject: Re: Syntax to crop variable labels

Hi,
 
Something like this might also do what you want:
 
set mprint = on.
get file = 'c:/program files/spss/employee data.sav'.
begin program.
import spss, spssaux
def truncate_labels(var, maxlen):
  vardict = spssaux.VariableDict()
  labels = vardict[var].ValueLabels
  for k, v in labels.iteritems():
    spss.Submit("add value labels %s %s '%s'."  % (var, k, v[0:maxlen] + "..."))
truncate_labels(var = "jobcat", maxlen = 3)
end program.

Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- On Mon, 7/5/10, Art Kendall <[hidden email]> wrote:

From: Art Kendall <[hidden email]>
Subject: Re: [SPSSX-L] Syntax to crop variable labels
To: [hidden email]
Date: Monday, July 5, 2010, 5:51 PM

copy the syntax below into a syntax window.  See if this is what you need. Then try replacing the piece of text in the syntax window between "begin data" and "end data" with the text from the other source.
copy the resulting print info into a new syntax window.

data list fixed /item (1x,f3) itemlabel(1x, a70).
begin data
(614)My assignments don't require using technology
(615)School filters or firewalls block websites I need to use
(616)Software is not good enough
(617)Teachers don't know how to use the technology
(618)Teachers limit our technology use
(619)There are rules against using technology at my school
(620)My school has different computers or software than I am used to
end data.
print  /'     ' item '"' itemlabel '"/'.
execute.

Art Kendall
Social Research Consultants

On 7/5/2010 11:29 AM, John F Hall wrote:
I am working on a file constructed by someone else.  There are hundreds of variable labels of the following type.  Rather than going through and deleting the brackets and their contents manually, is there any syntax to do it for me?  Otherwise I'll be at it all night.
 
TIA
 
John Hall
 
(614)My assignments don't require using technology
(615)School filters or firewalls block websites I need to use
(616)Software is not good enough
(617)Teachers don't know how to use the technology
(618)Teachers limit our technology use
(619)There are rules against using technology at my school
(620)My school has different computers or software than I am used to
===================== 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 crop variable labels

Bruce Weaver
Administrator
In reply to this post by John F Hall
John, just modify the PRINT command, in that case.  Judging by your post in the other thread, I think you want something like:

print  /' token_id.' item '"' itemlabel '"/'.

I get this for output:

 token_id.614 "My assignments don't require using technology                          "/
 token_id.615 "School filters or firewalls block websites I need to use               "/
 token_id.616 "Software is not good enough                                            "/
 token_id.617 "Teachers don't know how to use the technology                          "/
 token_id.618 "Teachers limit our technology use                                      "/
 token_id.619 "There are rules against using technology at my school                  "/
 token_id.620 "My school has different computers or software than I am used to        "/

Bruce


John F Hall wrote
Art

Thanks for the syntax: this is what I get:

     614 "My assignments don't require using technology                          "/

     615 "School filters or firewalls block websites I need to use               "/

     616 "Software is not good enough                                            "/

     617 "Teachers don't know how to use the technology                          "/

     618 "Teachers limit our technology use                                      "/

     619 "There are rules against using technology at my school                  "/

     620 "My school has different computers or software than I am used to        "/



but I don't want the numbers, just the text.  However, if the syntax can be amended to yield



     token614 "My assignments don't require using technology                          "/

     token615 "School filters or firewalls block websites I need to use               "/



I can then run var labels with the result.  This saves manually amending about 400 labels.



John



PS  I like my slashes at the beginning of the line (with a preceding space of course) where I can see them.





----- Original Message -----

  From: Art Kendall
  To: SPSSX-L@LISTSERV.UGA.EDU
  Sent: Monday, July 05, 2010 5:51 PM
  Subject: Re: Syntax to crop variable labels


  copy the syntax below into a syntax window.  See if this is what you need. Then try replacing the piece of text in the syntax window between "begin data" and "end data" with the text from the other source.
  copy the resulting print info into a new syntax window.

  data list fixed /item (1x,f3) itemlabel(1x, a70).
  begin data
  (614)My assignments don't require using technology
  (615)School filters or firewalls block websites I need to use
  (616)Software is not good enough
  (617)Teachers don't know how to use the technology
  (618)Teachers limit our technology use
  (619)There are rules against using technology at my school
  (620)My school has different computers or software than I am used to
  end data.
  print  /'     ' item '"' itemlabel '"/'.
  execute.

  Art Kendall
  Social Research Consultants

  On 7/5/2010 11:29 AM, John F Hall wrote:
    I am working on a file constructed by someone else.  There are hundreds of variable labels of the following type.  Rather than going through and deleting the brackets and their contents manually, is there any syntax to do it for me?  Otherwise I'll be at it all night.

    TIA

    John Hall

    (614)My assignments don't require using technology
    (615)School filters or firewalls block websites I need to use
    (616)Software is not good enough
    (617)Teachers don't know how to use the technology
    (618)Teachers limit our technology use
    (619)There are rules against using technology at my school
    (620)My school has different computers or software than I am used to
  ===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

R: Syntax to crop variable labels

Rita Clivio
Hi John

have you to follow this procedure a lot of time or one time only?

And if you copy your statements in excel and then using "Extract String" and
"Concat" you manage your labels?

I Know it's not a solution by syntax ... but semel in anno ...


Rita


-----Messaggio originale-----
Da: SPSSX(r) Discussion [mailto:[hidden email]] Per conto di Bruce
Weaver
Inviato: lunedì 5 luglio 2010 20.01
A: [hidden email]
Oggetto: Re: Syntax to crop variable labels

John, just modify the PRINT command, in that case.  Judging by your post in
the other thread, I think you want something like:

print  /' token_id.' item '"' itemlabel '"/'.

I get this for output:

 token_id.614 "My assignments don't require using technology
"/
 token_id.615 "School filters or firewalls block websites I need to use
"/
 token_id.616 "Software is not good enough
"/
 token_id.617 "Teachers don't know how to use the technology
"/
 token_id.618 "Teachers limit our technology use
"/
 token_id.619 "There are rules against using technology at my school
"/
 token_id.620 "My school has different computers or software than I am used
to        "/

Bruce



John F Hall wrote:

>
> Art
>
> Thanks for the syntax: this is what I get:
>
>      614 "My assignments don't require using technology
> "/
>
>      615 "School filters or firewalls block websites I need to use
> "/
>
>      616 "Software is not good enough
> "/
>
>      617 "Teachers don't know how to use the technology
> "/
>
>      618 "Teachers limit our technology use
> "/
>
>      619 "There are rules against using technology at my school
> "/
>
>      620 "My school has different computers or software than I am used to
> "/
>
>
>
> but I don't want the numbers, just the text.  However, if the syntax can
> be amended to yield
>
>
>
>      token614 "My assignments don't require using technology
> "/
>
>      token615 "School filters or firewalls block websites I need to use
> "/
>
>
>
> I can then run var labels with the result.  This saves manually amending
> about 400 labels.
>
>
>
> John
>
>
>
> PS  I like my slashes at the beginning of the line (with a preceding space
> of course) where I can see them.
>
>
>
>
>
> ----- Original Message -----
>
>   From: Art Kendall
>   To: [hidden email]
>   Sent: Monday, July 05, 2010 5:51 PM
>   Subject: Re: Syntax to crop variable labels
>
>
>   copy the syntax below into a syntax window.  See if this is what you
> need. Then try replacing the piece of text in the syntax window between
> "begin data" and "end data" with the text from the other source.
>   copy the resulting print info into a new syntax window.
>
>   data list fixed /item (1x,f3) itemlabel(1x, a70).
>   begin data
>   (614)My assignments don't require using technology
>   (615)School filters or firewalls block websites I need to use
>   (616)Software is not good enough
>   (617)Teachers don't know how to use the technology
>   (618)Teachers limit our technology use
>   (619)There are rules against using technology at my school
>   (620)My school has different computers or software than I am used to
>   end data.
>   print  /'     ' item '"' itemlabel '"/'.
>   execute.
>
>   Art Kendall
>   Social Research Consultants
>
>   On 7/5/2010 11:29 AM, John F Hall wrote:
>     I am working on a file constructed by someone else.  There are
> hundreds of variable labels of the following type.  Rather than going
> through and deleting the brackets and their contents manually, is there
> any syntax to do it for me?  Otherwise I'll be at it all night.
>
>     TIA
>
>     John Hall
>
>     (614)My assignments don't require using technology
>     (615)School filters or firewalls block websites I need to use
>     (616)Software is not good enough
>     (617)Teachers don't know how to use the technology
>     (618)Teachers limit our technology use
>     (619)There are rules against using technology at my school
>     (620)My school has different computers or software than I am used to
>   ===================== 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
>


-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."

NOTE:  My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
--
View this message in context:
http://old.nabble.com/Syntax-to-crop-variable-labels-tp29077097p29078281.htm
l
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
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.439 / Virus Database: 271.1.1/2983 - Release Date: 07/05/10
06:36:00

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

Output problem

Nirit Avnimelech
Hi all,

I'm sure you've been asked this, but I haven't been able to find any
reasonable answers - please help!
I have a client that wants me to produce tables that they can then work on
with their scripts.  The tables have to comply with a very strict table
look.
The problem?  They're sticking with v.14 (all their scripts etc. are for
that version), and I work with v.17...
The reader doesn't do me any good - I don't need to read .spo files, I need
to produce them!
Does anyone know of any conversion programs for converting .spv to .spo and
.tlo to .stt???

Any suggestion will be accepted with gratitude!

:-)

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