mercredi 1 mai 2019

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

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. a busy cat

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

Aucun commentaire:

Enregistrer un commentaire