Announcement

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

  • Creating Dummy Variables

    Hello,

    My name is Joway. I'm a college student in my last year taking my capstone course. I'm writing an econ paper on Chinese aid in Sub-Saharan Africa (SSA). I will probably be coming back here frequently because I am so new to Stata. For the past 3 days I have been trying to create a conflict dummy variable. In my regression, I look to assess for the affects of conflict on aid and for that I downloaded a conflict database and my objective was to create a dummy variable 1 if there is conflict and 2 if there's no conflict through a panel data set from 2000 to 2021 for 40+ African countries. Originally what I had in mind was to do a sort of cross-reference for the country in question and year. For example, for the year 2000, I wanted, originally Excel, but now Stata, to check if the country Angola is found in any of the five columns (location, side_a, side_a_2nd, side_b, side_b_2nd) and return a value of 1 if the country was mentioned in that year which would indicate it being involved in a conflict or return 0 which would mean it was not involved in a conflict. But I don't know anything about Stata, yet, and have been using ChatGPT to create a code to run, but to no avail. Attached is a code that ChatGPT came up with. I don't know anything about data analysis coding so I can't judge the merits of the code. Can anyone assist me with this?

    I attached my conflict database (excel) and the ChatGPT do-file (not sure if you need it or not)
    Attached Files

  • #2
    Joway:
    you can easily test what you're after via something along the following lines:
    Code:
    . use "C:\Program Files\Stata18\ado\base\a\auto.dta"
    (1978 automobile data)
    
    
    . egen wanted=rowmiss( make- foreign ) if make=="Buick Opel" | make=="AMC Concord"
    
    
    . list make wanted if make=="Buick Opel" | make=="AMC Concord"
    
         +----------------------+
         | make          wanted |
         |----------------------|
      1. | AMC Concord        0 |
      7. | Buick Opel         1 |
         +----------------------+
    *1=Buick Opel has missing data in at least one variable.*.
    .
    That said:
    1) as per FAQ, please do not post attachments (by the way, spreadsheets will not be downloaded due to the risk of active contents), bit use CODE delimiters and -dataex- to share your materials;
    2) ChatGPT is not always the most reliable way to learn Stata. In addition, you should declare for what you used it in research reports (dissertations included; there might be some ethical issue that creeps up, too) and papers submitted to techinal journal.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment

    Working...
    X