Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8585277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:01:09+00:00 2026-06-11T22:01:09+00:00

Some datasets come with full-lowercase value labels, and I end up with graphs and

  • 0

Some datasets come with full-lowercase value labels, and I end up with graphs and tables showing results for “egypt”, “jordan” and “saudi arabia” instead of the capitalized country names.

I guess that the proper() string function can do something for me, but I am not finding the right way to write the code for Stata 11 that will capitalize all value labels for a given variable.

I basically need to run the proper() function on all value labels on the variable, and then assign them to the variable. Is that possible using a foreach loop and macros in Stata?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:01:11+00:00Added an answer on June 11, 2026 at 10:01 pm

    Yes. First let’s create some sample data with labels for testing:

    clear
    drawnorm x, n(10)
    gen byte v = int(4+x)
    drop x
    label define types 0 "zero" 1 "one" 2 "two" 3 "three" 4 "four" 5 "five" 6 "six"
    label list types
    label values v types
    

    Here’s a macro to capitalize the values associated with the variable “v”:

    local varname v
    local sLabelName: value label `varname'
    di "`sLabelName'"
    
    levelsof `varname', local(xValues)
    foreach x of local xValues {
        local sLabel: label (`varname') `x', strict
        local sLabelNew =proper("`sLabel'")
        noi di "`x': `sLabel' ==> `sLabelNew'"
        label define `sLabelName' `x' "`sLabelNew'", modify
    }
    

    After running it, check the results:

    label list types
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some queries which group datasets and count them, e.g. SELECT COUNT(*) FROM
I've written some very basic tools for grouping, pivoting, unioning and subtotaling datasets sourced
Im using LINQ over DataSet but just to get data from some tables, by
I've been pulling my hair out trying to get some data to come across
I'm extracting some xml from an XFA static form. Here is a sample: <xfa:datasets
There are some large datasets (25gb+, downloadable on the Internet) that I want to
I'm going over some SQL I wrote a while ago that joins 4 tables
I have a web application that loads some 50 tables from SQL Server into
i'm updating some VB6 code to .NET and have come across a small problem.
For a project, I need to replicate some results that currently exist in Stata

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.