Announcement

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

  • getting multiple variables information in one variable after importing txt file

    After importing delimited using abcd.txt data this is the following output I'm getting on my data editor.

    The first four-digit should have been year, the next 2 digits represent State postal abbreviation, the next 2 digits express State FIPS code, the next 3 digits represent County FIPS code, and the next 2 digits are for Registry (Geographic Definition Only), the following single digit is for the race, the next digit is for Hispanic. The next digits are for gender, then the following 2 digits are for age (00-85), and the last 8 digits are for the population. The dictionary is also explained here if anyone cares to go through it. Also, NBER uploaded the refined dataset here ( 1990-2016 ) dta

    How can I refine it like the dictionary of the data? So far, after importing it this is what it looks like. It's importing only 1 variable in name of v1 whereas there is information of 10 variables I put it in bold form.

    Any suggestion ? I need the data from 2000-2020. Otherwise I could have used the NBER uploaded data where they uploaded it till 2016 from 1990.

    This is the dictionary of the data

    https://seer.cancer.gov/popdata/popdic.html



    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str26 v1
    "1990AL01001991010000000239"
    "1990AL01001991010100000190"
    "1990AL01001991010200000203"
    "1990AL01001991010300000220"
    "1990AL01001991010400000208"
    "1990AL01001991010500000216"
    "1990AL01001991010600000204"
    "1990AL01001991010700000198"
    "1990AL01001991010800000219"
    "1990AL01001991010900000252"
    "1990AL01001991011000000255"
    "1990AL01001991011100000224"
    "1990AL01001991021100000196"
    "1990AL01001991021200000192"
    "1990AL01001991021300000197"
    end

  • #2
    THIS IS HOW NBER UPLOADED IT dta

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int year str2(st stfips) str5 county byte(registry race hispanic sex age) long pop
    1990 "AL" "01" "01001" 99 1 1 1 0    2
    1990 "AL" "01" "01001" 99 1 0 1 0  239
    1990 "AL" "01" "01001" 99 1 1 2 0    1
    1990 "AL" "01" "01001" 99 1 0 2 0  203
    1990 "AL" "01" "01001" 99 2 0 1 0   51
    1990 "AL" "01" "01001" 99 2 0 2 0   57
    1990 "AL" "01" "01001" 99 4 0 1 0    1
    1990 "AL" "01" "01001" 99 4 0 2 0    1
    1990 "AL" "01" "01001" 99 1 1 1 1    7
    1990 "AL" "01" "01001" 99 1 0 1 1  821
    1990 "AL" "01" "01001" 99 1 0 2 1  769
    1990 "AL" "01" "01001" 99 1 1 2 1    7
    1990 "AL" "01" "01001" 99 4 0 1 8    4
    1990 "AL" "01" "01001" 99 4 0 2 8   10
    1990 "AL" "01" "01001" 99 1 0 1 9 1051
    1990 "AL" "01" "01001" 99 1 1 1 9    5
    1990 "AL" "01" "01001" 99 1 1 2 9    9
    end
    label values registry registry
    label def registry 99 "Registry for non-SEER area", modify
    label values race race
    label def race 1 "White", modify
    label def race 2 "Black", modify
    label def race 3 "American Indian/Alaska Native (1990+)", modify
    label def race 4 "Asian or Pacific Islander (1990+)", modify
    label values hispanic hispanic
    label def hispanic 0 "Non-Hispanic", modify
    label def hispanic 1 "Hispanic", modify
    label values sex sex
    label def sex 1 "Male", modify
    label def sex 2 "Female", modify
    label values age age
    label def age 0 "0 years", modify
    label def age 1 "1-4 years", modify
    label def age 2 "5-9 years", modify
    label def age 3 "10-14 years", modify
    label def age 4 "15-19 years", modify
    label def age 5 "20-24 years", modify
    label def age 6 "25-29 years", modify
    label def age 7 "30-34 years", modify
    label def age 8 "35-39 years", modify
    label def age 9 "40-44 years", modify

    Comment


    • #3
      The text file you are importing is not a delimited file, it is a fixed-format file. So -import delimited- is the wrong tool. You need to use the -infix- command for this. See -help infix- for instructions: you can either create a data dictionary for it, or you can incorporate the field definitions directly into the -infix- command.

      Comment


      • #4
        Thanks so much, Mr. Schechter! After reading through helpfiles and a couple of related posts from statalist I successfully figure out what to do! Much obliged for your time

        Comment

        Working...
        X