Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generate New Variable to define data from within the same data set

    Hi,
    I have a data set which include a variable for "state". I want to generate a new variable called "region" which is the combination of all states in that region. So for example, I want region "Northeast" to include connecticut, maine, massachusetts, new hampshire, rhode island, vermont, new jersey, new york and pennsylvania. How would I code for this?

    Thanks

  • #2
    As another example, I am trying to generate a new variable "stress echo" by combining variables cpt like this:

    . generate stress echo=(cpt=="93350" & cpt=="93351")
    too many variables specified
    r(103);

    But keep receiving the error code.

    Thanks for the help

    Comment


    • #3
      You can find a downloadable .csv file linking states to US Census regions and divisions at https://www.kaggle.com/datasets/omer...ates-to-region. Download it, use -import delimited- to make a Stata data file out of it, and then -merge- it with your existing data set.

      Added: Crossed with #2. #2 is completely off topic from the original title of the thread. A new thread should have been started. That said, you cannot create a variable called -stress echo- because a Stata variable name cannot contain embedded blanks. Change the variable name to stress_echo and your command will work.

      In the future, please start a new thread whenever you are asking a question unrelated to what has preceded in the thread.
      Last edited by Clyde Schechter; 01 Sep 2022, 11:35.

      Comment


      • #4
        Thanks, I will start another thread with follow up question to the second point.

        Comment

        Working...
        X