As of 2018, this command not works resulting from Fb API restrictions.
In a earlier publish, we launched a brand new command to import Twitter information into Stata. We’ve got now added one other new command, facebook2stata, that imports Fb information. To put in facebook2stata, sort
web set up https://www.stata.com/customers/kcrow/facebook2stata, exchange
As soon as put in, you are able to do the next
- Import occasion information utilizing a search string
facebook2stata searchevents "search_string"
facebook2stata searchgroups "search_string"
facebook2stata searchpages "search_string"
facebook2stata searchplaces "search_string"
facebook2stata searchusers "search_string"
Like twitter2stata, there may be some required setup along with your Fb account to make this command work in Stata. You could make your individual Fb app for facebook2stata to work. The steps are as follows:
- To make use of this command, you need to have a Fb account. In the event you don’t have one, you’ll be able to create one right here.
- Subsequent, login to your Fb account and go to right here. Click on on the Create a New App button.
- Subsequent, give your app a reputation and e mail deal with.
-
Now, you will want to repeat the generated App ID and App Secret to a do-file. You will want each of them to make use of the command.
Subsequent, click on on the Instruments & Assist menu.
- It’s best to now see

- Now, click on on the Entry Token Software button.
- On this web page, that you must click on the must grant permissions hyperlink to generate your Person Token.
- You will want to repeat the Person Token to a do-file.
-
NOTE: The Person Token that was generated is a short-term token lasting just a few days. You possibly can extened the token for 60 days by clicking on the Debug button. It’s best to see
To increase the token, click on on the Lengthen Entry Token button.
In contrast to twitter2stata, the info out there to import from Fb are considerably restricted. The principle limitation of Fb information is that if you wish to entry an individual’s information, they need to give your Fb app permission to take action. The occasion, group, place, and web page information have much less restriction.
Once more, you’ll want to copy the
- App ID
- App Secret
- Person Token
and paste them right into a do-file, for instance,
native user_token "74741598400768-3hAYpZbiDvABPizx5lk57B8CTVyfa" native app_secret "7D25oVzWeDCHrUlQcp9929@GOcnqWCuUKhDel" native app_id "xWNlx*N9vESv0ZZBtGdm7fVB"
Ensure not to share these with anyone else.
In the identical do-file, add the command
facebook2stata setaccess "`user_token'" "`app_id'" "`app_secret'"
to initialize these settings for facebook2stata. In the event you don’t use facebook2stata setaccess … earlier than every facebook2stata session, you’ll obtain the error under:
. facebook2stata searchgroups "star wars", rely(10) consumer token, app id, or app secret not set. Run facebook2stata setaccess to set your consumer token, app id, and app secret. r(198);
My do-file is now
native user_token "74741598400768-3hAYpZbiDvABPizx5lk57B8CTVyfa" native app_secret "7D25oVzWeDCHrUlQcp9929@GOcnqWCuUKhDel" native app_id "xWNlx*N9vESv0ZZBtGdm7fVB" facebook2stata setaccess "`user_token'" "`app_id'" "`app_secret'" facebook2stata searchgroups "star wars", rely(10) checklist
After I run the do-file, I get
. facebook2stata searchevents "star wars", rely(10)
(7 vars, 10 obs)
. checklist group_name group_owner_name
+---------------------------------------------------------------+
| group_name group_owner_name |
|---------------------------------------------------------------|
1. | Star Wars OlÃvio Farias |
2. | Star Wars Brasil João Carlos Damasceno |
3. | STAR WARS GRUPO FANS Ervin Ramirez |
4. | STAR WARS - Greek Fan Membership Stelios Kourtis |
5. | Star Wars Coleccionistas / Collectors Moi Rdz |
|---------------------------------------------------------------|
6. | Star Wars Sithposting |
7. | Star Wars Universe David Alonso |
8. | STAR WARS: Something & Every little thing Steve Sabbai |
9. | Star Wars Verrückte Frank Lichters |
10. | Star Wars Followers Italia |
+---------------------------------------------------------------+
There are limits to the quantity of knowledge Fb will allow you to import. These limits are subcommand-specific and restrict the variety of calls you can also make to Fb’s webpage. Click on right here to see the info charge limits for the Graph API.
In case you have every other social media information you want to import, be at liberty to publish your suggestion in our feedback. You possibly can learn the total particulars of facebook2stata‘s performance in its assist file after putting in it.





