Announcement

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

  • Creating variable out of conditional values in another one (GDELT)

    Hello everyone. Let me first describe my data and purpose of analysis for the sake of context.
    I have quite a large conflict dataset (71 mill obs) with many variables, and date (daily). This is from the GDELT project which I think is amazing, but comments aside, the way the dataset is structured is that for each day, there is a target country and a source country of aggression. Namely, the first of January of 2000, many countries engaged in aggressive behaviour against others or themselves, and this dataset tracks this.

    It looks like this.
    Click image for larger version

Name:	list1.png
Views:	1
Size:	18.0 KB
ID:	1496041


    Cameo code is a level of intensity of conflict measured with some algorithm that tracks the news in each language. Very insightful.
    Now what I would like to do is to isolate this events per country. So for instance, I would like to create a variable for the US where, for each date, I have all the times that the US was either a target or a source, and their respective cameo code.

    Obviously what I am going to write is horribly wrong and I apologise for it already, but I would like a logical statement similar to something like: generate new variable(USAconflict) If (source or target) =USA, extract cameo codes next to date.

    I hope I have expressed myself correctly. I have tried to look in the forum as well as in stackoverflow but I have not found anything that really applies to my case.

    Thanks in advance for any help.

    Best regards,

    Juana

  • #2
    I am sorry for using a screenshot and not an example as in the FAQ advice #12 but I tried and it looked horrible and I think this is more informative? Im sorry for not sticking to rule #12, hope is not a big deal.

    Comment


    • #3
      Ok I managed to create the example. Sorry guys.

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input long date_01 str18 source_01 str19 target_01 str4 cameocode_01
      20000101 "AFG"    "AFGGOV" "020" 
      20000101 "AFG"    "AFGGOV" "0841"
      20000101 "AFG"    "ARE"    "036" 
      20000101 "AFG"    "CVL"    "043" 
      20000101 "AFG"    "GOV"    "010" 
      20000101 "AFG"    "GOV"    "043" 
      20000101 "AFGGOV" "kasUAF" "0353"
      20000101 "AFGGOV" "kasUAF" "084" 
      20000101 "AFG"    "IGOUNO" "030" 
      20000101 "AFG"    "IND"    "042" 
      20000101 "AFG"    "IND"    "043" 
      
      end

      Comment

      Working...
      X