First letters of labels all in lower case

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

First letters of labels all in lower case

John F Hall

I’ve just downloaded the first two waves of Understanding Society (previously the British Household Panel Survey).  In wave 1 (N = 50994; V = 1340) there are no question numbers on the main (Blaise) questionnaire, only variable names.  In the SPSS *.sav file the variable labels all start with a lower case letter:

 

Variable Labels

Variable

Position

Label

a_promodeny

367

turned down for promotion

a_respromodeny1

368

your sex

a_respromodeny2

369

your age

a_respromodeny3

370

your ethnicity

a_respromodeny4

371

your sexual orientation

a_respromodeny5

372

your health or disability

a_respromodeny6

373

your nationality

a_respromodeny7

374

your religion

a_respromodeny8

375

your language or accent

a_respromodeny9

376

your dress or appearance

a_respromodeny96

377

none of the above

a_respromodeny97

378

other reason

Variables in the working file

 

So do all the value labels:

 

a_jbsat job satisfaction

 

Frequency

Percent

Valid Percent

Cumulative Percent

Valid

-9 missing

7

.0

.0

.0

-8 inapplicable

21433

42.0

42.0

42.0

-7 proxy

3262

6.4

6.4

48.4

-2 refused

18

.0

.0

48.5

-1 don't know

81

.2

.2

48.6

1 completely dissatisfied

837

1.6

1.6

50.3

2 mostly dissatisfied

1060

2.1

2.1

52.4

3 somewhat dissatisfied

2021

4.0

4.0

56.3

4 neither satisfied or dissatisfied

1955

3.8

3.8

60.2

5 somewhat satisfied

4433

8.7

8.7

68.8

6 mostly satisfied

11034

21.6

21.6

90.5

7 completedly satisfied

4853

9.5

9.5

100.0

Total

50994

100.0

100.0

 

 

No missing values have been declared, but at least they are consistent for all variables and can be specified as (-9 thru -1) but is there a quick Python way to make all first letters upper case in both variable and value labels?

 

John F Hall (Mr)

[Retired academic survey researcher]

 

Email:   [hidden email] 

Website: www.surveyresearch.weebly.com

SPSS start page:  www.surveyresearch.weebly.com/spss-without-tears.html

  

  

 

 

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: First letters of labels all in lower case

Bruce Weaver
Administrator
John, here is a NPR (no Python required)  solution that seems to do the trick.  ;-)  


* Modify the FILE HANDLE commands to point to where you have
* the SPSS sample data files stored on your computer and where
* you have a TEMP folder.

FILE HANDLE TheDataFile /NAME="C:\SPSSdata\survey_sample.sav".
FILE HANDLE TempFolder /NAME="C:\Temp".

NEW FILE.
DATASET CLOSE all.
GET FILE="TheDataFile".
DATASET NAME raw.

DATASET DECLARE  Values.
DATASET DECLARE  VarInfo.
OMS
  /SELECT TABLES
  /IF COMMANDS=['Sysfile Info'] SUBTYPES=['Value Labels']
  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
   OUTFILE='Values' VIEWER=NO.
* OMS.
OMS
  /SELECT TABLES
  /IF COMMANDS=['Sysfile Info'] SUBTYPES=['Variable Information']
  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
   OUTFILE='VarInfo' VIEWER=NO.

SYSFILE INFO FILE = 'C:\SPSSdata\survey_sample.sav'.

OMSEND.

* Now use DM's "ginger-haired bastard" approach:
* Write VARIABLE LABLE and ADD VALUE LABELS commands
* to syntax files, then include them via INSERT.

DATASET ACTIVATE VarInfo.
* Replace first letter of variable LABEL with it's uppercase version.
COMPUTE Label =
 REPLACE(Label,CHAR.SUBSTR(Label,1,1), UPPER(CHAR.SUBSTR(Label,1,1))).
WRITE OUTFILE =
 'TempFolder\NewVarLab.sps' / 'VARIABLE LABELS ',Var1, ' ','"',Label,'".'.
EXECUTE.
DATASET ACTIVATE raw.
INSERT FILE = 'TempFolder\NewVarLab.sps'.

DATASET ACTIVATE Values.
* Replace first letter of variable LABEL with it's uppercase version.
COMPUTE Label =
 REPLACE(Label,CHAR.SUBSTR(Label,1,1), UPPER(CHAR.SUBSTR(Label,1,1))).
WRITE OUTFILE =
 'TempFolder\NewValueLab.sps' / 'ADD VALUE LABELS ',Var1,' ',Var2,' "',Label,'".'.
EXECUTE.
DATASET ACTIVATE raw.
INSERT FILE = 'TempFolder\NewValueLab.sps'.

DISPLAY DICTIONARY.

* Clean up the junk.

ERASE FILE = 'TempFolder\NewVarLab.sps'.
ERASE FILE = 'TempFolder\NewValueLab.sps'.



John F Hall wrote
I've just downloaded the first two waves of Understanding Society
(previously the British Household Panel Survey).  In wave 1 (N = 50994; V =
1340) there are no question numbers on the main (Blaise) questionnaire, only
variable names.  In the SPSS *.sav file the variable labels all start with a
lower case letter:


Variable Labels

Variable
Position
Label

a_promodeny
367
turned down for promotion

a_respromodeny1
368
your sex

a_respromodeny2
369
your age

a_respromodeny3
370
your ethnicity

a_respromodeny4
371
your sexual orientation

a_respromodeny5
372
your health or disability

a_respromodeny6
373
your nationality

a_respromodeny7
374
your religion

a_respromodeny8
375
your language or accent

a_respromodeny9
376
your dress or appearance

a_respromodeny96
377
none of the above

a_respromodeny97
378
other reason

Variables in the working file

So do all the value labels:


a_jbsat job satisfaction


Frequency
Percent
Valid Percent
Cumulative Percent

Valid
-9 missing
7
.0
.0
.0

-8 inapplicable
21433
42.0
42.0
42.0

-7 proxy
3262
6.4
6.4
48.4

-2 refused
18
.0
.0
48.5

-1 don't know
81
.2
.2
48.6

1 completely dissatisfied
837
1.6
1.6
50.3

2 mostly dissatisfied
1060
2.1
2.1
52.4

3 somewhat dissatisfied
2021
4.0
4.0
56.3

4 neither satisfied or dissatisfied
1955
3.8
3.8
60.2

5 somewhat satisfied
4433
8.7
8.7
68.8

6 mostly satisfied
11034
21.6
21.6
90.5

7 completedly satisfied
4853
9.5
9.5
100.0

Total
50994
100.0
100.0


No missing values have been declared, but at least they are consistent for
all variables and can be specified as (-9 thru -1) but is there a quick
Python way to make all first letters upper case in both variable and value
labels?

John F Hall (Mr)
[Retired academic survey researcher]

Email:    <mailto:[hidden email]> [hidden email]
Website:  <http://www.surveyresearch.weebly.com>
www.surveyresearch.weebly.com
SPSS start page:
<http://www.surveyresearch.weebly.com/spss-without-tears.html>
www.surveyresearch.weebly.com/spss-without-tears.html
--
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
|

Re: First letters of labels all in lower case

Jon K Peck
Horrible, horrible!

Try this:

begin program.
import spss, spssaux
vd = spssaux.VariableDict()
for v in vd:
    varlabel = v.VariableLabel
    if varlabel:
        v.VariableLabel = varlabel.capitalize()
    vallbls = v.ValueLabels
    for k in vallbls:
        vallbls[k] = vallbls[k].capitalize()
    if vallbls:
        v.ValueLabels = vallbls
end program.


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




From:        Bruce Weaver <[hidden email]>
To:        [hidden email],
Date:        10/09/2013 10:04 AM
Subject:        Re: [SPSSX-L] First letters of labels all in lower case
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




John, here is a NPR (no Python required)  solution that seems to do the
trick.  ;-)


* Modify the FILE HANDLE commands to point to where you have
* the SPSS sample data files stored on your computer and where
* you have a TEMP folder.

FILE HANDLE TheDataFile /NAME="C:\SPSSdata\survey_sample.sav".
FILE HANDLE TempFolder /NAME="C:\Temp".

NEW FILE.
DATASET CLOSE all.
GET FILE="TheDataFile".
DATASET NAME raw.

DATASET DECLARE  Values.
DATASET DECLARE  VarInfo.
OMS
 /SELECT TABLES
 /IF COMMANDS=['Sysfile Info'] SUBTYPES=['Value Labels']
 /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
  OUTFILE='Values' VIEWER=NO.
* OMS.
OMS
 /SELECT TABLES
 /IF COMMANDS=['Sysfile Info'] SUBTYPES=['Variable Information']
 /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
  OUTFILE='VarInfo' VIEWER=NO.

SYSFILE INFO FILE = 'C:\SPSSdata\survey_sample.sav'.

OMSEND.

* Now use DM's "ginger-haired bastard" approach:
* Write VARIABLE LABLE and ADD VALUE LABELS commands
* to syntax files, then include them via INSERT.

DATASET ACTIVATE VarInfo.
* Replace first letter of variable LABEL with it's uppercase version.
COMPUTE Label =
REPLACE(Label,CHAR.SUBSTR(Label,1,1), UPPER(CHAR.SUBSTR(Label,1,1))).
WRITE OUTFILE =
'TempFolder\NewVarLab.sps' / 'VARIABLE LABELS ',Var1, ' ','"',Label,'".'.
EXECUTE.
DATASET ACTIVATE raw.
INSERT FILE = 'TempFolder\NewVarLab.sps'.

DATASET ACTIVATE Values.
* Replace first letter of variable LABEL with it's uppercase version.
COMPUTE Label =
REPLACE(Label,CHAR.SUBSTR(Label,1,1), UPPER(CHAR.SUBSTR(Label,1,1))).
WRITE OUTFILE =
'TempFolder\NewValueLab.sps' / 'ADD VALUE LABELS ',Var1,' ',Var2,'
"',Label,'".'.
EXECUTE.
DATASET ACTIVATE raw.
INSERT FILE = 'TempFolder\NewValueLab.sps'.

DISPLAY DICTIONARY.

* Clean up the junk.

ERASE FILE = 'TempFolder\NewVarLab.sps'.
ERASE FILE = 'TempFolder\NewValueLab.sps'.




John F Hall wrote
> I've just downloaded the first two waves of Understanding Society
> (previously the British Household Panel Survey).  In wave 1 (N = 50994; V
> =
> 1340) there are no question numbers on the main (Blaise) questionnaire,
> only
> variable names.  In the SPSS *.sav file the variable labels all start with
> a
> lower case letter:
>
>
> Variable Labels
>
> Variable
> Position
> Label
>
> a_promodeny
> 367
> turned down for promotion
>
> a_respromodeny1
> 368
> your sex
>
> a_respromodeny2
> 369
> your age
>
> a_respromodeny3
> 370
> your ethnicity
>
> a_respromodeny4
> 371
> your sexual orientation
>
> a_respromodeny5
> 372
> your health or disability
>
> a_respromodeny6
> 373
> your nationality
>
> a_respromodeny7
> 374
> your religion
>
> a_respromodeny8
> 375
> your language or accent
>
> a_respromodeny9
> 376
> your dress or appearance
>
> a_respromodeny96
> 377
> none of the above
>
> a_respromodeny97
> 378
> other reason
>
> Variables in the working file
>
> So do all the value labels:
>
>
> a_jbsat job satisfaction
>
>
> Frequency
> Percent
> Valid Percent
> Cumulative Percent
>
> Valid
> -9 missing
> 7
> .0
> .0
> .0
>
> -8 inapplicable
> 21433
> 42.0
> 42.0
> 42.0
>
> -7 proxy
> 3262
> 6.4
> 6.4
> 48.4
>
> -2 refused
> 18
> .0
> .0
> 48.5
>
> -1 don't know
> 81
> .2
> .2
> 48.6
>
> 1 completely dissatisfied
> 837
> 1.6
> 1.6
> 50.3
>
> 2 mostly dissatisfied
> 1060
> 2.1
> 2.1
> 52.4
>
> 3 somewhat dissatisfied
> 2021
> 4.0
> 4.0
> 56.3
>
> 4 neither satisfied or dissatisfied
> 1955
> 3.8
> 3.8
> 60.2
>
> 5 somewhat satisfied
> 4433
> 8.7
> 8.7
> 68.8
>
> 6 mostly satisfied
> 11034
> 21.6
> 21.6
> 90.5
>
> 7 completedly satisfied
> 4853
> 9.5
> 9.5
> 100.0
>
> Total
> 50994
> 100.0
> 100.0
>
>
> No missing values have been declared, but at least they are consistent for
> all variables and can be specified as (-9 thru -1) but is there a quick
> Python way to make all first letters upper case in both variable and value
> labels?
>
> John F Hall (Mr)
> [Retired academic survey researcher]
>
> Email:    &lt;mailto:

> johnfhall@

> &gt;

> johnfhall@

> Website:  &lt;
http://www.surveyresearch.weebly.com&gt;
>
www.surveyresearch.weebly.com
> SPSS start page:
> &lt;
http://www.surveyresearch.weebly.com/spss-without-tears.html&gt;
>
www.surveyresearch.weebly.com/spss-without-tears.html





-----
--
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://spssx-discussion.1045642.n5.nabble.com/First-letters-of-labels-all-in-lower-case-tp5722462p5722466.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


Reply | Threaded
Open this post in threaded view
|

Re: First letters of labels all in lower case

John F Hall

Jon

 

You’re a genius.  You’ve saved me and others hours of work.

 

It’s worked on most of the file, but there are a few warnings. 

 

GET

  FILE='C:\Users\John\AppData\Local\Temp\Temp5_6614.zip\UKDA-6614-spss\spss\spss14\a_indresp.sav'.

DATASET NAME DataSet1 WINDOW=FRONT.

begin program.

import spss, spssaux

vd = spssaux.VariableDict()

for v in vd:

    varlabel = v.VariableLabel

    if varlabel:

        v.VariableLabel = varlabel.capitalize()

    vallbls = v.ValueLabels

    for k in vallbls:

        vallbls[k] = vallbls[k].capitalize()

    if vallbls:

        v.ValueLabels = vallbls

end program.

 

Warning # 208 in column 1011.  Text: Metal machin

A text string is not correctly enclosed in quotation marks on the command

line.  Literals may not be continued across command lines without the use of

the continuation symbol '+'.

 

Warning # 208 in column 1019.  Text: Refu

A text string is not correctly enclosed in quotation marks on the command

line.  Literals may not be continued across command lines without the use of

the continuation symbol '+'.

 

Warning # 208 in column 1021.  Text: Me

A text string is not correctly enclosed in quotation marks on the command

line.  Literals may not be continued across command lines without the use of

the continuation symbol '+'.

 

Warning # 208 in column 1011.  Text: Metal machin

A text string is not correctly enclosed in quotation marks on the command

line.  Literals may not be continued across command lines without the use of

the continuation symbol '+'.

 

Warning # 208 in column 1021.  Text: Me

A text string is not correctly enclosed in quotation marks on the command

line.  Literals may not be continued across command lines without the use of

the continuation symbol '+'.

 

Warning # 208 in column 1011.  Text: Metal machin

A text string is not correctly enclosed in quotation marks on the command

line.  Literals may not be continued across command lines without the use of

the continuation symbol '+'.

 

Warning # 208 in column 1007.  Text: Administrative o

A text string is not correctly enclosed in quotation marks on the command

line.  Literals may not be continued across command lines without the use of

the continuation symbol '+'.

 

Warning # 208 in column 1011.  Text: Metal machin

A text string is not correctly enclosed in quotation marks on the command

line.  Literals may not be continued across command lines without the use of

the continuation symbol '+'.

 

Warning # 208 in column 1007.  Text: Administrative o

A text string is not correctly enclosed in quotation marks on the command

line.  Literals may not be continued across command lines without the use of

the continuation symbol '+'.

 

Warning # 208 in column 1011.  Text: Metal machin

A text string is not correctly enclosed in quotation marks on the command

line.  Literals may not be continued across command lines without the use of

the continuation symbol '+'.

 

Warning # 208 in column 1007.  Text: Administrative o

A text string is not correctly enclosed in quotation marks on the command

line.  Literals may not be continued across command lines without the use of

the continuation symbol '+'.

 

I can probably locate and correct these by hand, unless it’s a simple amendment to the Python code.

 

John

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jon K Peck
Sent: 09 October 2013 18:29
To: [hidden email]
Subject: Re: First letters of labels all in lower case

 

Horrible, horrible!

Try this:

begin program.
import spss, spssaux
vd = spssaux.VariableDict()
for v in vd:
    varlabel = v.VariableLabel
    if varlabel:
        v.VariableLabel = varlabel.capitalize()
    vallbls = v.ValueLabels
    for k in vallbls:
        vallbls[k] = vallbls[k].capitalize()
    if vallbls:
        v.ValueLabels = vallbls
end program.


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




From:        Bruce Weaver <[hidden email]>
To:        [hidden email],
Date:        10/09/2013 10:04 AM
Subject:        Re: [SPSSX-L] First letters of labels all in lower case
Sent by:        "SPSSX(r) Discussion" <[hidden email]>





John, here is a NPR (no Python required)  solution that seems to do the
trick.  ;-)


* Modify the FILE HANDLE commands to point to where you have
* the SPSS sample data files stored on your computer and where
* you have a TEMP folder.

FILE HANDLE TheDataFile /NAME="C:\SPSSdata\survey_sample.sav".
FILE HANDLE TempFolder /NAME="C:\Temp".

NEW FILE.
DATASET CLOSE all.
GET FILE="TheDataFile".
DATASET NAME raw.

DATASET DECLARE  Values.
DATASET DECLARE  VarInfo.
OMS
 /SELECT TABLES
 /IF COMMANDS=['Sysfile Info'] SUBTYPES=['Value Labels']
 /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
  OUTFILE='Values' VIEWER=NO.
* OMS.
OMS
 /SELECT TABLES
 /IF COMMANDS=['Sysfile Info'] SUBTYPES=['Variable Information']
 /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
  OUTFILE='VarInfo' VIEWER=NO.

SYSFILE INFO FILE = 'C:\SPSSdata\survey_sample.sav'.

OMSEND.

* Now use DM's "ginger-haired bastard" approach:
* Write VARIABLE LABLE and ADD VALUE LABELS commands
* to syntax files, then include them via INSERT.

DATASET ACTIVATE VarInfo.
* Replace first letter of variable LABEL with it's uppercase version.
COMPUTE Label =
REPLACE(Label,CHAR.SUBSTR(Label,1,1), UPPER(CHAR.SUBSTR(Label,1,1))).
WRITE OUTFILE =
'TempFolder\NewVarLab.sps' / 'VARIABLE LABELS ',Var1, ' ','"',Label,'".'.
EXECUTE.
DATASET ACTIVATE raw.
INSERT FILE = 'TempFolder\NewVarLab.sps'.

DATASET ACTIVATE Values.
* Replace first letter of variable LABEL with it's uppercase version.
COMPUTE Label =
REPLACE(Label,CHAR.SUBSTR(Label,1,1), UPPER(CHAR.SUBSTR(Label,1,1))).
WRITE OUTFILE =
'TempFolder\NewValueLab.sps' / 'ADD VALUE LABELS ',Var1,' ',Var2,'
"',Label,'".'.
EXECUTE.
DATASET ACTIVATE raw.
INSERT FILE = 'TempFolder\NewValueLab.sps'.

DISPLAY DICTIONARY.

* Clean up the junk.

ERASE FILE = 'TempFolder\NewVarLab.sps'.
ERASE FILE = 'TempFolder\NewValueLab.sps'.




John F Hall wrote
> I've just downloaded the first two waves of Understanding Society
> (previously the British Household Panel Survey).  In wave 1 (N = 50994; V
> =
> 1340) there are no question numbers on the main (Blaise) questionnaire,
> only
> variable names.  In the SPSS *.sav file the variable labels all start with
> a
> lower case letter:
>
>
> Variable Labels
>
> Variable
> Position
> Label
>
> a_promodeny
> 367
> turned down for promotion
>
> a_respromodeny1
> 368
> your sex
>
> a_respromodeny2
> 369
> your age
>
> a_respromodeny3
> 370
> your ethnicity
>
> a_respromodeny4
> 371
> your sexual orientation
>
> a_respromodeny5
> 372
> your health or disability
>
> a_respromodeny6
> 373
> your nationality
>
> a_respromodeny7
> 374
> your religion
>
> a_respromodeny8
> 375
> your language or accent
>
> a_respromodeny9
> 376
> your dress or appearance
>
> a_respromodeny96
> 377
> none of the above
>
> a_respromodeny97
> 378
> other reason
>
> Variables in the working file
>
> So do all the value labels:
>
>
> a_jbsat job satisfaction
>
>
> Frequency
> Percent
> Valid Percent
> Cumulative Percent
>
> Valid
> -9 missing
> 7
> .0
> .0
> .0
>
> -8 inapplicable
> 21433
> 42.0
> 42.0
> 42.0
>
> -7 proxy
> 3262
> 6.4
> 6.4
> 48.4
>
> -2 refused
> 18
> .0
> .0
> 48.5
>
> -1 don't know
> 81
> .2
> .2
> 48.6
>
> 1 completely dissatisfied
> 837
> 1.6
> 1.6
> 50.3
>
> 2 mostly dissatisfied
> 1060
> 2.1
> 2.1
> 52.4
>
> 3 somewhat dissatisfied
> 2021
> 4.0
> 4.0
> 56.3
>
> 4 neither satisfied or dissatisfied
> 1955
> 3.8
> 3.8
> 60.2
>
> 5 somewhat satisfied
> 4433
> 8.7
> 8.7
> 68.8
>
> 6 mostly satisfied
> 11034
> 21.6
> 21.6
> 90.5
>
> 7 completedly satisfied
> 4853
> 9.5
> 9.5
> 100.0
>
> Total
> 50994
> 100.0
> 100.0
>
>
> No missing values have been declared, but at least they are consistent for
> all variables and can be specified as (-9 thru -1) but is there a quick
> Python way to make all first letters upper case in both variable and value
> labels?
>
> John F Hall (Mr)
> [Retired academic survey researcher]
>
> Email:    &lt;mailto:

> johnfhall@

> &gt;

> johnfhall@

> Website:  &lt;
http://www.surveyresearch.weebly.com&gt;
>
www.surveyresearch.weebly.com
> SPSS start page:
> &lt;
http://www.surveyresearch.weebly.com/spss-without-tears.html&gt;
>
www.surveyresearch.weebly.com/spss-without-tears.html





-----
--
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://spssx-discussion.1045642.n5.nabble.com/First-letters-of-labels-all-in-lower-case-tp5722462p5722466.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

Reply | Threaded
Open this post in threaded view
|

Re: First letters of labels all in lower case

hillel vardi
In reply to this post by John F Hall

Shalom

Python  solution  will defiantly by sorter  but syntax  solution   is also simple   here is an example using the "U.S. General Social Survey"

file from the SPSS samples.



DATASET CLOSE all.
get  FILE='C:\Program Files (x86)\EpiTools\SPSSInc\PASWStatistics18\Samples\English\1991 U.S. General Social Survey.sav'.
DATASET NAME socio .


DATASET DECLARE  valuelbl.
OMS
  /SELECT TABLES
  /IF COMMANDS=['File Information'] SUBTYPES=['Variable Values']
  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_    OUTFILE='valuelbl'.

DATASET DECLARE  varlbl.
OMS
  /SELECT TABLES
  /IF COMMANDS=['File Information'] SUBTYPES=['Variable Information']
  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_    OUTFILE='varlbl'.

DISPLAY DICTIONARY .

OMSEND .
OMSEND .

DATASET ACTIVATE valuelbl .
string value_lable(a100).
compute value_lable=concat('VARIABLE LABELS    '  ,var1,string(var2,f4), "      '",rtrim(Label), "' .").
print OUTFILE='c:\temp\value_lable.sps' /value_lable  .
execute .
DATASET ACTIVATE socio .
INSERT  FILE='c:\temp\value_lable.sps' .

DATASET ACTIVATE varlbl .
string var_lable(a100).
compute var_lable=concat('VARIABLE LABELS    '  ,var1,'       "',
    UPCASE(substr(Label,1,1)), rtrim(substr(Label,2,length(Label)-1)),'" . ' ).
print OUTFILE='c:\temp\var_lable.sps' /var_lable  .
execute .
DATASET ACTIVATE socio .
INSERT  FILE='c:\temp\var_lable.sps' .


Hillel Vardi
BGU

On 09/10/2013 15:14, John F Hall wrote:

I’ve just downloaded the first two waves of Understanding Society (previously the British Household Panel Survey).  In wave 1 (N = 50994; V = 1340) there are no question numbers on the main (Blaise) questionnaire, only variable names.  In the SPSS *.sav file the variable labels all start with a lower case letter:

 

Variable Labels

Variable

Position

Label

a_promodeny

367

turned down for promotion

a_respromodeny1

368

your sex

a_respromodeny2

369

your age

a_respromodeny3

370

your ethnicity

a_respromodeny4

371

your sexual orientation

a_respromodeny5

372

your health or disability

a_respromodeny6

373

your nationality

a_respromodeny7

374

your religion

a_respromodeny8

375

your language or accent

a_respromodeny9

376

your dress or appearance

a_respromodeny96

377

none of the above

a_respromodeny97

378

other reason

Variables in the working file

 

So do all the value labels:

 

a_jbsat job satisfaction

 

Frequency

Percent

Valid Percent

Cumulative Percent

Valid

-9 missing

7

.0

.0

.0

-8 inapplicable

21433

42.0

42.0

42.0

-7 proxy

3262

6.4

6.4

48.4

-2 refused

18

.0

.0

48.5

-1 don't know

81

.2

.2

48.6

1 completely dissatisfied

837

1.6

1.6

50.3

2 mostly dissatisfied

1060

2.1

2.1

52.4

3 somewhat dissatisfied

2021

4.0

4.0

56.3

4 neither satisfied or dissatisfied

1955

3.8

3.8

60.2

5 somewhat satisfied

4433

8.7

8.7

68.8

6 mostly satisfied

11034

21.6

21.6

90.5

7 completedly satisfied

4853

9.5

9.5

100.0

Total

50994

100.0

100.0

 

 

No missing values have been declared, but at least they are consistent for all variables and can be specified as (-9 thru -1) but is there a quick Python way to make all first letters upper case in both variable and value labels?

 

John F Hall (Mr)

[Retired academic survey researcher]

 

Email:   [hidden email] 

Website: www.surveyresearch.weebly.com

SPSS start page:  www.surveyresearch.weebly.com/spss-without-tears.html

  

  

 

 

 

 

 


Reply | Threaded
Open this post in threaded view
|

Re: First letters of labels all in lower case

Bruce Weaver
Administrator
In reply to this post by Jon K Peck
And there I was, thinking you'd be pleased I used FILE HANDLE rather than macros to define paths and file names!  ;-)


Jon K Peck wrote
Horrible, horrible!

Try this:

begin program.
import spss, spssaux
vd = spssaux.VariableDict()
for v in vd:
    varlabel = v.VariableLabel
    if varlabel:
        v.VariableLabel = varlabel.capitalize()
    vallbls = v.ValueLabels
    for k in vallbls:
        vallbls[k] = vallbls[k].capitalize()
    if vallbls:
        v.ValueLabels = vallbls
end program.


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




From:   Bruce Weaver <[hidden email]>
To:     [hidden email],
Date:   10/09/2013 10:04 AM
Subject:        Re: [SPSSX-L] First letters of labels all in lower case
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



John, here is a NPR (no Python required)  solution that seems to do the
trick.  ;-)


* Modify the FILE HANDLE commands to point to where you have
* the SPSS sample data files stored on your computer and where
* you have a TEMP folder.

FILE HANDLE TheDataFile /NAME="C:\SPSSdata\survey_sample.sav".
FILE HANDLE TempFolder /NAME="C:\Temp".

NEW FILE.
DATASET CLOSE all.
GET FILE="TheDataFile".
DATASET NAME raw.

DATASET DECLARE  Values.
DATASET DECLARE  VarInfo.
OMS
  /SELECT TABLES
  /IF COMMANDS=['Sysfile Info'] SUBTYPES=['Value Labels']
  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
   OUTFILE='Values' VIEWER=NO.
* OMS.
OMS
  /SELECT TABLES
  /IF COMMANDS=['Sysfile Info'] SUBTYPES=['Variable Information']
  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
   OUTFILE='VarInfo' VIEWER=NO.

SYSFILE INFO FILE = 'C:\SPSSdata\survey_sample.sav'.

OMSEND.

* Now use DM's "ginger-haired bastard" approach:
* Write VARIABLE LABLE and ADD VALUE LABELS commands
* to syntax files, then include them via INSERT.

DATASET ACTIVATE VarInfo.
* Replace first letter of variable LABEL with it's uppercase version.
COMPUTE Label =
 REPLACE(Label,CHAR.SUBSTR(Label,1,1), UPPER(CHAR.SUBSTR(Label,1,1))).
WRITE OUTFILE =
 'TempFolder\NewVarLab.sps' / 'VARIABLE LABELS ',Var1, ' ','"',Label,'".'.
EXECUTE.
DATASET ACTIVATE raw.
INSERT FILE = 'TempFolder\NewVarLab.sps'.

DATASET ACTIVATE Values.
* Replace first letter of variable LABEL with it's uppercase version.
COMPUTE Label =
 REPLACE(Label,CHAR.SUBSTR(Label,1,1), UPPER(CHAR.SUBSTR(Label,1,1))).
WRITE OUTFILE =
 'TempFolder\NewValueLab.sps' / 'ADD VALUE LABELS ',Var1,' ',Var2,'
"',Label,'".'.
EXECUTE.
DATASET ACTIVATE raw.
INSERT FILE = 'TempFolder\NewValueLab.sps'.

DISPLAY DICTIONARY.

* Clean up the junk.

ERASE FILE = 'TempFolder\NewVarLab.sps'.
ERASE FILE = 'TempFolder\NewValueLab.sps'.




John F Hall wrote
> I've just downloaded the first two waves of Understanding Society
> (previously the British Household Panel Survey).  In wave 1 (N = 50994;
V
> =
> 1340) there are no question numbers on the main (Blaise) questionnaire,
> only
> variable names.  In the SPSS *.sav file the variable labels all start
with
> a
> lower case letter:
>
>
> Variable Labels
>
> Variable
> Position
> Label
>
> a_promodeny
> 367
> turned down for promotion
>
> a_respromodeny1
> 368
> your sex
>
> a_respromodeny2
> 369
> your age
>
> a_respromodeny3
> 370
> your ethnicity
>
> a_respromodeny4
> 371
> your sexual orientation
>
> a_respromodeny5
> 372
> your health or disability
>
> a_respromodeny6
> 373
> your nationality
>
> a_respromodeny7
> 374
> your religion
>
> a_respromodeny8
> 375
> your language or accent
>
> a_respromodeny9
> 376
> your dress or appearance
>
> a_respromodeny96
> 377
> none of the above
>
> a_respromodeny97
> 378
> other reason
>
> Variables in the working file
>
> So do all the value labels:
>
>
> a_jbsat job satisfaction
>
>
> Frequency
> Percent
> Valid Percent
> Cumulative Percent
>
> Valid
> -9 missing
> 7
> .0
> .0
> .0
>
> -8 inapplicable
> 21433
> 42.0
> 42.0
> 42.0
>
> -7 proxy
> 3262
> 6.4
> 6.4
> 48.4
>
> -2 refused
> 18
> .0
> .0
> 48.5
>
> -1 don't know
> 81
> .2
> .2
> 48.6
>
> 1 completely dissatisfied
> 837
> 1.6
> 1.6
> 50.3
>
> 2 mostly dissatisfied
> 1060
> 2.1
> 2.1
> 52.4
>
> 3 somewhat dissatisfied
> 2021
> 4.0
> 4.0
> 56.3
>
> 4 neither satisfied or dissatisfied
> 1955
> 3.8
> 3.8
> 60.2
>
> 5 somewhat satisfied
> 4433
> 8.7
> 8.7
> 68.8
>
> 6 mostly satisfied
> 11034
> 21.6
> 21.6
> 90.5
>
> 7 completedly satisfied
> 4853
> 9.5
> 9.5
> 100.0
>
> Total
> 50994
> 100.0
> 100.0
>
>
> No missing values have been declared, but at least they are consistent
for
> all variables and can be specified as (-9 thru -1) but is there a quick
> Python way to make all first letters upper case in both variable and
value
> labels?
>
> John F Hall (Mr)
> [Retired academic survey researcher]
>
> Email:    <mailto:

> johnfhall@

> >

> johnfhall@

> Website:  <http://www.surveyresearch.weebly.com>
> www.surveyresearch.weebly.com
> SPSS start page:
> <http://www.surveyresearch.weebly.com/spss-without-tears.html>
> www.surveyresearch.weebly.com/spss-without-tears.html





-----
--
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://spssx-discussion.1045642.n5.nabble.com/First-letters-of-labels-all-in-lower-case-tp5722462p5722466.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
--
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
|

Re: First letters of labels all in lower case

Jon K Peck
I'll give you credit for that, but notice:
SYSFILE INFO FILE = 'C:\SPSSdata\survey_sample.sav'.

And notice that this code won't work in the presence of double quote characters in the label text.


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




From:        Bruce Weaver <[hidden email]>
To:        [hidden email],
Date:        10/10/2013 05:12 AM
Subject:        Re: [SPSSX-L] First letters of labels all in lower case
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




And there I was, thinking you'd be pleased I used FILE HANDLE rather than
macros to define paths and file names!  ;-)



Jon K Peck wrote
> Horrible, horrible!
>
> Try this:
>
> begin program.
> import spss, spssaux
> vd = spssaux.VariableDict()
> for v in vd:
>     varlabel = v.VariableLabel
>     if varlabel:
>         v.VariableLabel = varlabel.capitalize()
>     vallbls = v.ValueLabels
>     for k in vallbls:
>         vallbls[k] = vallbls[k].capitalize()
>     if vallbls:
>         v.ValueLabels = vallbls
> end program.
>
>
> Jon Peck (no "h") aka Kim
> Senior Software Engineer, IBM

> peck@.ibm

> phone: 720-342-5621
>
>
>
>
> From:   Bruce Weaver &lt;

> bruce.weaver@

> &gt;
> To:

> SPSSX-L@.uga

> ,
> Date:   10/09/2013 10:04 AM
> Subject:        Re: [SPSSX-L] First letters of labels all in lower case
> Sent by:        "SPSSX(r) Discussion" &lt;

> SPSSX-L@.uga

> &gt;
>
>
>
> John, here is a NPR (no Python required)  solution that seems to do the
> trick.  ;-)
>
>
> * Modify the FILE HANDLE commands to point to where you have
> * the SPSS sample data files stored on your computer and where
> * you have a TEMP folder.
>
> FILE HANDLE TheDataFile /NAME="C:\SPSSdata\survey_sample.sav".
> FILE HANDLE TempFolder /NAME="C:\Temp".
>
> NEW FILE.
> DATASET CLOSE all.
> GET FILE="TheDataFile".
> DATASET NAME raw.
>
> DATASET DECLARE  Values.
> DATASET DECLARE  VarInfo.
> OMS
>   /SELECT TABLES
>   /IF COMMANDS=['Sysfile Info'] SUBTYPES=['Value Labels']
>   /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
>    OUTFILE='Values' VIEWER=NO.
> * OMS.
> OMS
>   /SELECT TABLES
>   /IF COMMANDS=['Sysfile Info'] SUBTYPES=['Variable Information']
>   /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
>    OUTFILE='VarInfo' VIEWER=NO.
>
> SYSFILE INFO FILE = 'C:\SPSSdata\survey_sample.sav'.
>
> OMSEND.
>
> * Now use DM's "ginger-haired bastard" approach:
> * Write VARIABLE LABLE and ADD VALUE LABELS commands
> * to syntax files, then include them via INSERT.
>
> DATASET ACTIVATE VarInfo.
> * Replace first letter of variable LABEL with it's uppercase version.
> COMPUTE Label =
>  REPLACE(Label,CHAR.SUBSTR(Label,1,1), UPPER(CHAR.SUBSTR(Label,1,1))).
> WRITE OUTFILE =
>  'TempFolder\NewVarLab.sps' / 'VARIABLE LABELS ',Var1, ' ','"',Label,'".'.
> EXECUTE.
> DATASET ACTIVATE raw.
> INSERT FILE = 'TempFolder\NewVarLab.sps'.
>
> DATASET ACTIVATE Values.
> * Replace first letter of variable LABEL with it's uppercase version.
> COMPUTE Label =
>  REPLACE(Label,CHAR.SUBSTR(Label,1,1), UPPER(CHAR.SUBSTR(Label,1,1))).
> WRITE OUTFILE =
>  'TempFolder\NewValueLab.sps' / 'ADD VALUE LABELS ',Var1,' ',Var2,'
> "',Label,'".'.
> EXECUTE.
> DATASET ACTIVATE raw.
> INSERT FILE = 'TempFolder\NewValueLab.sps'.
>
> DISPLAY DICTIONARY.
>
> * Clean up the junk.
>
> ERASE FILE = 'TempFolder\NewVarLab.sps'.
> ERASE FILE = 'TempFolder\NewValueLab.sps'.
>
>
>
>
> John F Hall wrote
>> I've just downloaded the first two waves of Understanding Society
>> (previously the British Household Panel Survey).  In wave 1 (N = 50994;
> V
>> =
>> 1340) there are no question numbers on the main (Blaise) questionnaire,
>> only
>> variable names.  In the SPSS *.sav file the variable labels all start
> with
>> a
>> lower case letter:
>>
>>
>> Variable Labels
>>
>> Variable
>> Position
>> Label
>>
>> a_promodeny
>> 367
>> turned down for promotion
>>
>> a_respromodeny1
>> 368
>> your sex
>>
>> a_respromodeny2
>> 369
>> your age
>>
>> a_respromodeny3
>> 370
>> your ethnicity
>>
>> a_respromodeny4
>> 371
>> your sexual orientation
>>
>> a_respromodeny5
>> 372
>> your health or disability
>>
>> a_respromodeny6
>> 373
>> your nationality
>>
>> a_respromodeny7
>> 374
>> your religion
>>
>> a_respromodeny8
>> 375
>> your language or accent
>>
>> a_respromodeny9
>> 376
>> your dress or appearance
>>
>> a_respromodeny96
>> 377
>> none of the above
>>
>> a_respromodeny97
>> 378
>> other reason
>>
>> Variables in the working file
>>
>> So do all the value labels:
>>
>>
>> a_jbsat job satisfaction
>>
>>
>> Frequency
>> Percent
>> Valid Percent
>> Cumulative Percent
>>
>> Valid
>> -9 missing
>> 7
>> .0
>> .0
>> .0
>>
>> -8 inapplicable
>> 21433
>> 42.0
>> 42.0
>> 42.0
>>
>> -7 proxy
>> 3262
>> 6.4
>> 6.4
>> 48.4
>>
>> -2 refused
>> 18
>> .0
>> .0
>> 48.5
>>
>> -1 don't know
>> 81
>> .2
>> .2
>> 48.6
>>
>> 1 completely dissatisfied
>> 837
>> 1.6
>> 1.6
>> 50.3
>>
>> 2 mostly dissatisfied
>> 1060
>> 2.1
>> 2.1
>> 52.4
>>
>> 3 somewhat dissatisfied
>> 2021
>> 4.0
>> 4.0
>> 56.3
>>
>> 4 neither satisfied or dissatisfied
>> 1955
>> 3.8
>> 3.8
>> 60.2
>>
>> 5 somewhat satisfied
>> 4433
>> 8.7
>> 8.7
>> 68.8
>>
>> 6 mostly satisfied
>> 11034
>> 21.6
>> 21.6
>> 90.5
>>
>> 7 completedly satisfied
>> 4853
>> 9.5
>> 9.5
>> 100.0
>>
>> Total
>> 50994
>> 100.0
>> 100.0
>>
>>
>> No missing values have been declared, but at least they are consistent
> for
>> all variables and can be specified as (-9 thru -1) but is there a quick
>> Python way to make all first letters upper case in both variable and
> value
>> labels?
>>
>> John F Hall (Mr)
>> [Retired academic survey researcher]
>>
>> Email:    &lt;mailto:
>
>> johnfhall@
>
>> &gt;
>
>> johnfhall@
>
>> Website:  &lt;
http://www.surveyresearch.weebly.com&gt;
>>
www.surveyresearch.weebly.com
>> SPSS start page:
>> &lt;
http://www.surveyresearch.weebly.com/spss-without-tears.html&gt;
>>
www.surveyresearch.weebly.com/spss-without-tears.html
>
>
>
>
>
> -----
> --
> Bruce Weaver

> bweaver@

>
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://spssx-discussion.1045642.n5.nabble.com/First-letters-of-labels-all-in-lower-case-tp5722462p5722466.html
>
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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





-----
--
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://spssx-discussion.1045642.n5.nabble.com/First-letters-of-labels-all-in-lower-case-tp5722462p5722486.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


Reply | Threaded
Open this post in threaded view
|

Re: First letters of labels all in lower case

Bruce Weaver
Administrator
I had double-quotes originally, but changed to single-quotes because at least one value label in that file contained an apostrophe, and things crashed and burned the first time around.  ;-)


Jon K Peck wrote
I'll give you credit for that, but notice:
SYSFILE INFO FILE = 'C:\SPSSdata\survey_sample.sav'.

And notice that this code won't work in the presence of double quote
characters in the label text.


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




From:   Bruce Weaver <[hidden email]>
To:     [hidden email],
Date:   10/10/2013 05:12 AM
Subject:        Re: [SPSSX-L] First letters of labels all in lower case
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



And there I was, thinking you'd be pleased I used FILE HANDLE rather than
macros to define paths and file names!  ;-)



Jon K Peck wrote
> Horrible, horrible!
>
> Try this:
>
> begin program.
> import spss, spssaux
> vd = spssaux.VariableDict()
> for v in vd:
>     varlabel = v.VariableLabel
>     if varlabel:
>         v.VariableLabel = varlabel.capitalize()
>     vallbls = v.ValueLabels
>     for k in vallbls:
>         vallbls[k] = vallbls[k].capitalize()
>     if vallbls:
>         v.ValueLabels = vallbls
> end program.
>
>
> Jon Peck (no "h") aka Kim
> Senior Software Engineer, IBM

> peck@.ibm

> phone: 720-342-5621
>
>
>
>
> From:   Bruce Weaver <

> bruce.weaver@

> >
> To:

> SPSSX-L@.uga

> ,
> Date:   10/09/2013 10:04 AM
> Subject:        Re: [SPSSX-L] First letters of labels all in lower case
> Sent by:        "SPSSX(r) Discussion" <

> SPSSX-L@.uga

> >
>
>
>
> John, here is a NPR (no Python required)  solution that seems to do the
> trick.  ;-)
>
>
> * Modify the FILE HANDLE commands to point to where you have
> * the SPSS sample data files stored on your computer and where
> * you have a TEMP folder.
>
> FILE HANDLE TheDataFile /NAME="C:\SPSSdata\survey_sample.sav".
> FILE HANDLE TempFolder /NAME="C:\Temp".
>
> NEW FILE.
> DATASET CLOSE all.
> GET FILE="TheDataFile".
> DATASET NAME raw.
>
> DATASET DECLARE  Values.
> DATASET DECLARE  VarInfo.
> OMS
>   /SELECT TABLES
>   /IF COMMANDS=['Sysfile Info'] SUBTYPES=['Value Labels']
>   /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
>    OUTFILE='Values' VIEWER=NO.
> * OMS.
> OMS
>   /SELECT TABLES
>   /IF COMMANDS=['Sysfile Info'] SUBTYPES=['Variable Information']
>   /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
>    OUTFILE='VarInfo' VIEWER=NO.
>
> SYSFILE INFO FILE = 'C:\SPSSdata\survey_sample.sav'.
>
> OMSEND.
>
> * Now use DM's "ginger-haired bastard" approach:
> * Write VARIABLE LABLE and ADD VALUE LABELS commands
> * to syntax files, then include them via INSERT.
>
> DATASET ACTIVATE VarInfo.
> * Replace first letter of variable LABEL with it's uppercase version.
> COMPUTE Label =
>  REPLACE(Label,CHAR.SUBSTR(Label,1,1), UPPER(CHAR.SUBSTR(Label,1,1))).
> WRITE OUTFILE =
>  'TempFolder\NewVarLab.sps' / 'VARIABLE LABELS ',Var1, '
','"',Label,'".'.
> EXECUTE.
> DATASET ACTIVATE raw.
> INSERT FILE = 'TempFolder\NewVarLab.sps'.
>
> DATASET ACTIVATE Values.
> * Replace first letter of variable LABEL with it's uppercase version.
> COMPUTE Label =
>  REPLACE(Label,CHAR.SUBSTR(Label,1,1), UPPER(CHAR.SUBSTR(Label,1,1))).
> WRITE OUTFILE =
>  'TempFolder\NewValueLab.sps' / 'ADD VALUE LABELS ',Var1,' ',Var2,'
> "',Label,'".'.
> EXECUTE.
> DATASET ACTIVATE raw.
> INSERT FILE = 'TempFolder\NewValueLab.sps'.
>
> DISPLAY DICTIONARY.
>
> * Clean up the junk.
>
> ERASE FILE = 'TempFolder\NewVarLab.sps'.
> ERASE FILE = 'TempFolder\NewValueLab.sps'.
>
>
>
>
> John F Hall wrote
>> I've just downloaded the first two waves of Understanding Society
>> (previously the British Household Panel Survey).  In wave 1 (N = 50994;
> V
>> =
>> 1340) there are no question numbers on the main (Blaise) questionnaire,
>> only
>> variable names.  In the SPSS *.sav file the variable labels all start
> with
>> a
>> lower case letter:
>>
>>
>> Variable Labels
>>
>> Variable
>> Position
>> Label
>>
>> a_promodeny
>> 367
>> turned down for promotion
>>
>> a_respromodeny1
>> 368
>> your sex
>>
>> a_respromodeny2
>> 369
>> your age
>>
>> a_respromodeny3
>> 370
>> your ethnicity
>>
>> a_respromodeny4
>> 371
>> your sexual orientation
>>
>> a_respromodeny5
>> 372
>> your health or disability
>>
>> a_respromodeny6
>> 373
>> your nationality
>>
>> a_respromodeny7
>> 374
>> your religion
>>
>> a_respromodeny8
>> 375
>> your language or accent
>>
>> a_respromodeny9
>> 376
>> your dress or appearance
>>
>> a_respromodeny96
>> 377
>> none of the above
>>
>> a_respromodeny97
>> 378
>> other reason
>>
>> Variables in the working file
>>
>> So do all the value labels:
>>
>>
>> a_jbsat job satisfaction
>>
>>
>> Frequency
>> Percent
>> Valid Percent
>> Cumulative Percent
>>
>> Valid
>> -9 missing
>> 7
>> .0
>> .0
>> .0
>>
>> -8 inapplicable
>> 21433
>> 42.0
>> 42.0
>> 42.0
>>
>> -7 proxy
>> 3262
>> 6.4
>> 6.4
>> 48.4
>>
>> -2 refused
>> 18
>> .0
>> .0
>> 48.5
>>
>> -1 don't know
>> 81
>> .2
>> .2
>> 48.6
>>
>> 1 completely dissatisfied
>> 837
>> 1.6
>> 1.6
>> 50.3
>>
>> 2 mostly dissatisfied
>> 1060
>> 2.1
>> 2.1
>> 52.4
>>
>> 3 somewhat dissatisfied
>> 2021
>> 4.0
>> 4.0
>> 56.3
>>
>> 4 neither satisfied or dissatisfied
>> 1955
>> 3.8
>> 3.8
>> 60.2
>>
>> 5 somewhat satisfied
>> 4433
>> 8.7
>> 8.7
>> 68.8
>>
>> 6 mostly satisfied
>> 11034
>> 21.6
>> 21.6
>> 90.5
>>
>> 7 completedly satisfied
>> 4853
>> 9.5
>> 9.5
>> 100.0
>>
>> Total
>> 50994
>> 100.0
>> 100.0
>>
>>
>> No missing values have been declared, but at least they are consistent
> for
>> all variables and can be specified as (-9 thru -1) but is there a quick
>> Python way to make all first letters upper case in both variable and
> value
>> labels?
>>
>> John F Hall (Mr)
>> [Retired academic survey researcher]
>>
>> Email:    <mailto:
>
>> johnfhall@
>
>> >
>
>> johnfhall@
>
>> Website:  <http://www.surveyresearch.weebly.com>
>> www.surveyresearch.weebly.com
>> SPSS start page:
>> <http://www.surveyresearch.weebly.com/spss-without-tears.html>
>> www.surveyresearch.weebly.com/spss-without-tears.html
>
>
>
>
>
> -----
> --
> Bruce Weaver

> bweaver@

> 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://spssx-discussion.1045642.n5.nabble.com/First-letters-of-labels-all-in-lower-case-tp5722462p5722466.html

>
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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





-----
--
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://spssx-discussion.1045642.n5.nabble.com/First-letters-of-labels-all-in-lower-case-tp5722462p5722486.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
--
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/).