Hi all,
I'm trying to import data in JSON format into Stata to construct a time series and I've looked at the "insheetjson" guide but haven't been able to figure it out.
Say I want to import from the following url: http://stats.grok.se/json/en/201308/Bitcoin
My end goal is to have one variable where each row is a day (2013-08-01, 2013-08-02, etc), and one variable where each row is the number of page views.
So far I have:
gen str20 date=""
gen str20 views=""
insheetjson date views using "http://stats.grok.se/json/en/201308/Bitcoin", showresponse
I get this back:
Response from server:
{
"daily_views" :
{
"2013-08-26" : "7351",
"2013-08-27" : "9386",
"2013-08-28" : "9560",
"2013-08-19" : "10826",
"2013-08-18" : "6747",
"2013-08-31" : "5259",
"2013-08-29" : "8280",
"2013-08-15" : "13482",
"2013-08-14" : "15454",
"2013-08-17" : "7780",
"2013-08-16" : "11230",
"2013-08-11" : "6069",
"2013-08-10" : "5136",
"2013-08-13" : "11157",
"2013-08-12" : "10290",
"2013-08-30" : "7050",
"2013-08-20" : "11569",
"2013-08-21" : "11741",
"2013-08-22" : "10214",
"2013-08-23" : "8863",
"2013-08-24" : "6216",
"2013-08-25" : "5688",
"2013-08-08" : "11422",
"2013-08-09" : "8161",
"2013-08-06" : "6994",
"2013-08-07" : "7421",
"2013-08-04" : "5322",
"2013-08-05" : "8729",
"2013-08-02" : "6321",
"2013-08-03" : "5310",
"2013-08-01" : "6973"
},
"project" : "en",
"month" : "201308",
"rank" : "89",
"title" : "Bitcoin"
I'm not sure what to do from here. I want "daily_views" to correspond to all of the numbers denoting views, and I don't want 31 separate variables for each day, which is what I think I'd get if I used any of the dates as column names/selectors. If I add
tableselector("daily_views")
it tells me that "possible name candidates" for the columns are the dates ("2013-08-26", for instance). But when I try adding
col("2013-08-26")
it gives me an error that says:
injson_sheet() 3200 conformability error
<istmt>: - function returned error.
I've looked for solutions to this error online, but if I'm not mistaken, the error refers to some sort of incorrect matrix multiplication in mata where the matrices are not conformable...so I'm confused.
Thanks in advance! I really appreciate any help.
Best,
Daniel
I'm trying to import data in JSON format into Stata to construct a time series and I've looked at the "insheetjson" guide but haven't been able to figure it out.
Say I want to import from the following url: http://stats.grok.se/json/en/201308/Bitcoin
My end goal is to have one variable where each row is a day (2013-08-01, 2013-08-02, etc), and one variable where each row is the number of page views.
So far I have:
gen str20 date=""
gen str20 views=""
insheetjson date views using "http://stats.grok.se/json/en/201308/Bitcoin", showresponse
I get this back:
Response from server:
{
"daily_views" :
{
"2013-08-26" : "7351",
"2013-08-27" : "9386",
"2013-08-28" : "9560",
"2013-08-19" : "10826",
"2013-08-18" : "6747",
"2013-08-31" : "5259",
"2013-08-29" : "8280",
"2013-08-15" : "13482",
"2013-08-14" : "15454",
"2013-08-17" : "7780",
"2013-08-16" : "11230",
"2013-08-11" : "6069",
"2013-08-10" : "5136",
"2013-08-13" : "11157",
"2013-08-12" : "10290",
"2013-08-30" : "7050",
"2013-08-20" : "11569",
"2013-08-21" : "11741",
"2013-08-22" : "10214",
"2013-08-23" : "8863",
"2013-08-24" : "6216",
"2013-08-25" : "5688",
"2013-08-08" : "11422",
"2013-08-09" : "8161",
"2013-08-06" : "6994",
"2013-08-07" : "7421",
"2013-08-04" : "5322",
"2013-08-05" : "8729",
"2013-08-02" : "6321",
"2013-08-03" : "5310",
"2013-08-01" : "6973"
},
"project" : "en",
"month" : "201308",
"rank" : "89",
"title" : "Bitcoin"
I'm not sure what to do from here. I want "daily_views" to correspond to all of the numbers denoting views, and I don't want 31 separate variables for each day, which is what I think I'd get if I used any of the dates as column names/selectors. If I add
tableselector("daily_views")
it tells me that "possible name candidates" for the columns are the dates ("2013-08-26", for instance). But when I try adding
col("2013-08-26")
it gives me an error that says:
injson_sheet() 3200 conformability error
<istmt>: - function returned error.
I've looked for solutions to this error online, but if I'm not mistaken, the error refers to some sort of incorrect matrix multiplication in mata where the matrices are not conformable...so I'm confused.
Thanks in advance! I really appreciate any help.
Best,
Daniel
Comment