Change labels from upper to lower case

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Change labels from upper to lower case

John F Hall

Jon

 

You recently supplied Python code to solve a problem in which all variable and value labels were lower case.  See thread: “First letters of labels all in lower case”.  Your Python code changed all first letters of all labels to upper case, leaving only a few manual changes needed for embedded sets of initials, names of countries etc.

 

I have now encountered the opposite problem.  In the SPSS *.sav files distributed by the Roper Center for the NORC General Social Survey 2008 (used as an exemplar in Sweet and Grace-Martin), all variable variable and value labels are in UPPER CASE.  This makes for quite ugly printed output.   The file, probably for historical reasons, not only has upper case labels for everything, but also seems to restrict var names to 8, var labs to 40 and val labs to 16-20 characters.

 

disp lab /var marital to race .      

                                                           

Variable Labels

Variable

Position

Label

MARITAL

3

MARITAL STATUS

AGE

4

AGE OF RESPONDENT

EDUC

5

HIGHEST YEAR OF SCHOOL COMPLETED

DEGREE

6

RS HIGHEST DEGREE

SEX

7

RESPONDENTS SEX

RACE

8

RACE OF RESPONDENT

Variables in the working file

 

DEGREE RS HIGHEST DEGREE

 

Frequency

Percent

Valid Percent

Cumulative Percent

Valid

0 LT HIGH SCHOOL

297

14.7

14.7

14.7

1 HIGH SCHOOL

1003

49.6

49.6

64.3

2 JUNIOR COLLEGE

173

8.6

8.6

72.8

3 BACHELOR

355

17.5

17.6

90.4

4 GRADUATE

194

9.6

9.6

100.0

Total

2022

100.0

100.0

 

Missing

8 DK

1

.0

 

 

Total

2023

100.0

 

 

[NB Names + labels,values + labels both used when I explore files for the first time]

 

POSTLIFE BELIEF IN LIFE AFTER DEATH

 

Frequency

Percent

Valid Percent

Cumulative Percent

Valid

0 NO

332

16.4

18.6

18.6

1 YES

1455

71.9

81.4

100.0

Total

1787

88.3

100.0

 

Missing

8 DK

231

11.4

 

 

9 NA

5

.2

 

 

Total

236

11.7

 

 

Total

2023

100.0

 

 

 

I can copy/paste the Label column from Variable View in and out of Word to change the variable labels to lower case, but it will take for ever to change the value labels.  After that I can just run your previous Python code to restore first letters to upper case and then tidy up manually for initials etc. 

 

Labels IAP, DK and NA are consistent throughout for values specified as MISSING, but the actual values may not all be the same.

 

As with the British Social Attitudes series, the same procedure is applicable to the entire GSS series.  If I send you [off-list] an extract from the file, would you have time to knock out another bit of Python code to convert all upper case to lower case, except for freestanding IAP, DK and NA?  I can probably do the rest myself?

 

Thanks in advance

 

John

 

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