Announcement

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

  • Numerical Value is Changing to str10 when Importing from Excel (and other issues)

    Hello!

    I am currently trying to use the ONET Soc Code which has values such as 11-1011.00. When trying to destring after importing the Excel file, I am not able to. I even made sure that the option that says "import data as strings" is not checked. I'm not sure if I need to change the Excel sheet numbers so that they don't have the dash - or not.

    Additionally, when I am recoding a current dataset to have the same format as above (11-1011.00), Stata codes it as -1010 because it is subtracting the two numbers together. My code is the following

    Code:
    gen job = .
    replace job = 11-1011.00 if M540A ==003
    I tried to do the following code, but ended up with a type mismatch r(109); error

    Code:
    replace job = "11-1031.00" if M540A ==003
    Not sure if this is enough information, but hopefully I can get some guidance! Thank you!

  • #2
    The "-" is going to give you a string.

    destring job, ignore("-") g(job_num)

    Comment


    • #3
      Originally posted by George Ford View Post
      The "-" is going to give you a string.

      destring job, ignore("-") g(job_num)
      Thank you, George! That seems to have addressed my first issue with the ONET dataset. Just trying to figure out the second issue in my other dataset with the numbers turning into -1022 instead of 11-1011.00.

      Comment


      • #4
        import as string.

        Comment


        • #5
          Originally posted by George Ford View Post
          import as string.
          the data set i'm currently working with is one that I am recoding so that I can merge the ONET database with this current dataset.

          Comment


          • #6
            So the master data has the messed up identifier? Is it that way in excel?

            Comment


            • #7
              Originally posted by George Ford View Post
              So the master data has the messed up identifier? Is it that way in excel?
              so the master dataset (national survey for families and households) has a job variable that is numerical (M540A). I am generating a "job" variable where I'm replacing the M540A variable to something that can be merged with the Excel sheets I'm getting from ONET. However, when I tabulate job, the observations are ending up as negative values.

              Comment


              • #8
                The M540A variable is not from Excel? If it is, does it look different in Excel than in Stata?

                Are the job identifers the same across data sets, save the import issues?

                Comment


                • #9
                  Originally posted by George Ford View Post
                  The M540A variable is not from Excel? If it is, does it look different in Excel than in Stata?

                  Are the job identifers the same across data sets, save the import issues?
                  M540A is not from excel, it's from the master dataset (NSFH). I will be using ONET's "code" variable to match for the merge and create the "code" variable in NSFH (where the M540A lives aka the master dataset) after I create the "job" variable.

                  Comment


                  • #10
                    dataex parts of each dataset and the help will be better.

                    help dataex

                    Comment

                    Working...
                    X