# STATA

![](https://3496061366-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MDSpD50SdXxsYnU7P9D%2F-MKHetHGi-a_TSbyhuEU%2F-MKHfZ4Fnf5WYRiNa6EZ%2Fimage.png?alt=media\&token=89866e53-fca6-4468-8393-b61dd0f35b4b)

## STATA

### sdmxpdh

SDMXPDH is a version of the SDMXUSE Stata module, with the changes allowing users to connect to Pacific Data Hub .Stat API (PDH.stat). See the code [here](https://github.com/PacificCommunity/statasdmx).

Full credit goes to Sebastien Fontenay, Robert Picard, Nicholas Cox.

This module is a simple adaptation of the SDMXUSE module (Fontenay), which itself uses the MOSS module (Picard & Cox).

Sebastien Fontenay, 2016. "SDMXUSE: Stata module to import data from statistical agencies using the SDMX standard," Statistical Software Components S458231, Boston College Department of Economics, revised 30 Sep 2018.

Robert Picard & Nicholas J. Cox, 2011. "MOSS: Stata module to find multiple occurrences of substrings," Statistical Software Components S457261, Boston College Department of Economics, revised 29 Apr 2016.

### Installation

Instructions work for Stata SE 15.1 in Windows

Download `.ado` and `.sthlp` files from the Github repository [here](https://github.com/PacificCommunity/statasdmx).

In Stata, find your "PERSONAL" directory path with the command: `sysdir`

In Windows, go to the "PERSONAL" directory location. It is probably `C:\ado\personal\`. If the path doesn't seem to exist, make the necessary folders yourself.

Put `.ado` and `.sthlp` files inside your "PERSONAL" directory.

Restart Stata.

Check the install worked by bringing up the SDMXPDH help document: `help sdmxpdh`

### Quick start

PDH.stat resources are maintained by SPC (Pacific Community), so SPC is the provider for resources.

General command structure is: `sdmxpdh <resource> <provider>, <filters>`

#### See all dataflows from Pacific Data Hub

```r
sdmxpdh dataflow SPC, clear
list
```

#### Get all data for a dataflow

For example, use dataflow `DF_CPI` (Consumer Price Index)

```r
sdmxpdh data SPC, clear dataset(DF_CPI)
list
```

#### Get specific data for a dataflow

This time, we want `DF_CPI` time series data from 2005 to 2018, for countries Fiji and Guam.

```r
sdmxpdh data SPC, clear dataset(DF_CPI) dimensions(A.FJ+GU.INF.) start(2005) end(2018) timeseries
list
```

Using the `dimensions()` option is tricky, see the API [documentation ](https://docs.pacificdata.org/dotstat/api)for a guide.

#### Get a datastructure definition for a dataflow

Again, let's use `DF_CPI`.

```r
sdmxpdh datastructure SPC, clear dataset(DF_CPI)
list
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pacificdata.org/dotstat/plugins/stata.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
