Announcement

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

  • Changing organization of data so that each observation represents a new variable (I tried)

    Hello!

    I am working with a dataset that contains information about a set of electric vehicle charging stations, where each observation represents a specific charging station. The name of the charging station is contained in a variable called
    Code:
    station_name
    . This includes a variable called
    Code:
     review_text
    which contains all of the customer reviews for a specific station (delimited by }{), and another variable called
    Code:
    num_reviews
    that has the number of customer reviews.

    I'm trying to make a new file where each observation represents one customer review (with the reviews being stored in a new variable named
    Code:
     customer_review
    , and with another variable,
    Code:
    station_id
    that has the name of the station corresponding with the customer review. So, for example, if the original data set had 100 observation (one per station) with 5 reviews per station, the new file should have 500 observations (one per review).

    How can I do this? I would include some code I have tried but I have no idea how to start.
    Thanks!

  • #2
    My apologies for this formatting, it was my first time posting

    Comment


    • #3
      Most likely the solution will revolve around the -split- and -reshape long- commands. For more specific advice, please post example data, using the -dataex- command to do so. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

      When asking for help with code, always show example data. When showing example data, always use -dataex-.

      Comment


      • #4
        Cross-posted and answered at https://stackoverflow.com/questions/...presents-a-new

        Please note our policy on cross-posting, which is that you are asked to tell us about it.

        Comment


        • #5
          Policy explained at https://www.statalist.org/forums/help#crossposting

          Comment

          Working...
          X