Announcement

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

  • Destring all variables except one

    Hello!

    I am trying to destring all variables except one ("ID"). However, I don't know how to write the except part. How should I do it? I am using Stata/SE 15.0

    destring _all, replace force

    PS: Sorry if the question is really basic, it is my first day with Stata.

    Thanks in advance

    Delia
    Last edited by Delia Sanchez; 27 Jun 2018, 08:54.

  • #2
    Code:
    describe
    or

    Code:
    ds
    will show you your variable names. There are three possible cases:

    1. ID is the first variable followed by say alpha to omega. Then go

    Code:
    destring alpha-omega, replace force
    2. ID is the last variable preceded by say alpha to omega. Same solution.

    3. ID is somewhere in the middle, say alpha-mu ID nu-omega. Then it's

    Code:
    destring alpha-mu nu-omega, replace force
    There are other solutions, but these are the best on your first day.

    Comment


    • #3
      Welcome to Statalist, and to Stata, Delia.

      I'm sympathetic to you as a new user of Stata - it's a lot to absorb. And even worse if perhaps you are under pressure to produce some output quickly. Nevertheless, I'd like to encourage you to take a step back from your immediate tasks.

      When I began using Stata in a serious way, I started, as have others here, by reading my way through the Getting Started with Stata manual relevant to my setup. Chapter 18 then gives suggested further reading, much of which is in the Stata User's Guide, and I worked my way through much of that reading as well. There are a lot of examples to copy and paste into Stata's do-file editor to run yourself, and better yet, to experiment with changing the options to see how the results change.

      All of these manuals are included as PDFs in the Stata installation (since version 11) and are accessible from within Stata - for example, through the PDF Documentation section of Stata's Help menu. The objective in doing the reading was not so much to master Stata - years later and I'm still trying to do that - as to be sure I'd become familiar with a wide variety of important basic techniques, so that when the time came that I needed them, I might recall their existence, if not the full syntax, and know how to find out more about them in the help files and PDF manuals.

      Stata supplies exceptionally good documentation that amply repays the time spent studying it - there's just a lot of it. The path I followed surfaces the things you need to know to get started in a hurry and to work effectively.

      Good luck!

      Comment


      • #4
        Since Delia is just beginning, let me suggest she also consider creating new variables rather than replacing the original string with the real variable. While this creates a mess of variables (you can always delete them), it reduces the confusion of having a variable name mean two different things in the same program. She will also want to list the original and the real after she destrings to make sure they came out right.

        Comment

        Working...
        X