Announcement

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

  • Problem with the data form a multi-line Excel cell

    Dear community,

    I loaded an Excel file where two columns contain more than one line (The cell includes, for example, industry classification of firms--firms can have more than one industry code. The database that I use puts each code in one line in the Excel sheet). When I import the Excel file to Stata something weird happens:

    -The value of the cells under that column appears in one line and the carriage returns seem to appear as spaces at the end of the string (when I -br- the data). I tried using the dataex to show you the data. But, dataex does not capture the problem. So, here is how I see the data:

    Click image for larger version

Name:	fig1.JPG
Views:	1
Size:	35.6 KB
ID:	1664749

    The first line is fine. The second line is supposed to contain these industry codes:
    524210
    524126
    524128
    524130

    When I count the number of characters for this line, Stata tells me that it has 27 characters (6*4 +3)

    But, then I -ltrim- (or rtrim) the variable, there seems to be no space at the end. When I try to list and see the value, I see this:

    Click image for larger version

Name:	fig2.JPG
Views:	1
Size:	24.1 KB
ID:	1664750


    Here it seems that carriage returns appear as spaces between the 6-digit codes. But, when I try to split this based on spaces, nothing is split.

    So, the issue is that the spaces (produced through space carriages in Excel) seem to be at the end of the string when I browse the data. When I list the data, they seem to be between 6-digit codes.

    What is going on here? How can I split these industry codes into different cells or put a punctuation mark between them?

    Thanks,
    Navid





  • #2
    Is the excel file publically avaliable? That is, is the excel file easily importable, like say
    Code:
    import exc "http://www.demoscope.ru/weekly/app/app4087.xls", clear
    EDIT: The reason I ask is because for questions like this that involve importing stuff and so on, having access to the real dataset if it's public can be helpful.
    Last edited by Jared Greathouse; 15 May 2022, 16:38.

    Comment


    • #3
      Hi Jared,

      Here it is: https://file.io/yIUt1UdZOrFY

      Good idea!

      Thanks,
      Navid

      Comment


      • #4
        It says the transfer file requested has been deleted. What's the website this is coming from? Are you sure it's publically free to those who want it?

        Comment

        Working...
        X