Announcement

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

  • Automatically parse selectors with insheetjson

    Hi all,

    I am trying to build a program that gets data from Statistics Denmark's API using insheetjson in Stata. However, I have not been able to find a solution for the following problem: I want to get the metadata from a random table (in this case: "FOLK1A" which is a table of demographics). This table has variables of region, age, marital status and time. If we take regions as an example, there are 105 regions, so if I run
    Code:
    insheetjson using "https://api.statbank.dk/v1/tableinfo/FOLK1A?lang=en", showresponse flatten
    I see a very clear pattern:
    Code:
            variables:1:values:1:id = 000
            variables:1:values:1:text = All Denmark
            variables:1:values:2:id = 084
            variables:1:values:2:text = Region Hovedstaden
            variables:1:values:3:id = 101
            variables:1:values:3:text = Copenhagen
            variables:1:values:4:id = 147
            variables:1:values:4:text = Frederiksberg
            variables:1:values:5:id = 155
            variables:1:values:5:text = Dragør
            variables:1:values:6:id = 185
            variables:1:values:6:text = Tårnby
            variables:1:values:7:id = 165
            variables:1:values:7:text = Albertslund
            variables:1:values:8:id = 151
            variables:1:values:8:text = Ballerup
            variables:1:values:9:id = 153
            variables:1:values:9:text = Brøndby
            variables:1:values:10:id = 157
            variables:1:values:10:text = Gentofte
    ...
            variables:1:values:100:text = Mariagerfjord
            variables:1:values:101:id = 773
            variables:1:values:101:text = Morsø
            variables:1:values:102:id = 840
            variables:1:values:102:text = Rebild
            variables:1:values:103:id = 787
            variables:1:values:103:text = Thisted
            variables:1:values:104:id = 820
            variables:1:values:104:text = Vesthimmerlands
            variables:1:values:105:id = 851
            variables:1:values:105:text = Aalborg
    However, I am not able not parse all these regions in a single call. Is there a way to tell insheetjson to get all of these regions, i.e. "variables:1:values:[1-105]:id" in one call? I don't want to run the command several times, thus pinging the server way too much.

    Best regards,
    Emil Blicher



    Last edited by Emil Blicher; 16 Dec 2021, 18:10. Reason: Added tags

  • #2
    Cross-posted at https://stackoverflow.com/questions/...tjson-in-stata

    Comment

    Working...
    X