Announcement

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

  • Adding Counties to States in Dataset

    Hello,

    I am conducting data analysis at the county level. One of the datasets I am using simply writes “(All Counties)” under the “County Variable.” This is problematic as I am calculating the HHI at the county level. Further below are two tables - Table 1 shows the current dataset, and Table 2 shows what I would like it to look like.

    Does anyone have advice on the code I use to make the data look like the Table below? I can pull the counties by state from U.S. Census Bureau.

    Table 1. Current Dataset
    State County
    Alabama (All Counties)


    Table 2. What the Data Needs to Look Like
    State County
    Alabama Autauga County
    Alabama Baldwin County
    Alabama Barbour County
    Alabama Bibb County
    Alabama Blount County
    Last edited by Christina Rockwell; 06 Jul 2022, 18:47.

  • #2
    Using Statalist is just like making wild mushroom risotto. If I asked you to make my favorite version of risotto, you'd likely need to know what the SPECIFIC ingredients are and the steps you do to make said dish.
    So far you've given neither, you're asking us for help to make a dish, and you've not given the recipe (the code) or ingredients (the data).

    Precisely, you must give your dataset using dataex and your code that you've tried (formatted accordingly). No dataset, no code=no real assistance. Read this page for details.

    Welcome to Statalist, Christina Rockwell.

    Comment


    • #3
      You do not need to add all the counties to Table 1 in order to merge it to your other data that is at the state-and-county level.

      The basic approach is, in the abstract,
      Code:
      use primarydata
      merge m:1 state table1
      Perhaps that's enough to start you in a useful direction. But if you need actual code, you need to show us some actual data, as discussed in post #2.


      Comment

      Working...
      X