> For the complete documentation index, see [llms.txt](https://pic-sure.gitbook.io/service-workbench/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pic-sure.gitbook.io/service-workbench/aim-ahead/accessing-ochin-data/phase-2-data-exploration.md).

# Phase 2: Data Exploration

This section covers how to use a SageMaker workspace to access OCHIN data and save your data subsets for later analysis.

Create a SageMaker workspace

<details>

<summary>Create your workspace</summary>

Step 1: Navigate to the **Studies** page. The organization studies are linked to Amazon S3 secure storage. This means that anything saved in these study folders will be securely saved and accessible through any workspace the study is mounted to.&#x20;

For more information about studies, view the documentation [here](https://pic-sure.gitbook.io/service-workbench/general-user-guide/studies).&#x20;

Step 2: Select the **Organizations** tab

Step 3: Select the **FHIR-Collaborative-Program** Organization

Step 4: Click **Next**

Step 5: Select the Sagemaker Notebook as shown below

Step 6: Click **Next**

Step 7: Enter a name: *Any name. Note that the Name can contain only alphanumeric characters (case sensitive) and hyphens. It must start with an alphabetic character and cannot be longer than 128 characters.*

*No change necessary for the **Restricted CIDR** field*

Step 8: Select the **Project Id** dropdown

Step 9: Select your AIM AHEAD affiliation: *For FHIR test data users, the project should appear as **FHIR-Collaborative-Program***

Step 10: Select a **sagemaker-small** workspace. *Note: It is recommended to start with a small workspace, especially during a limited time training as the larger workspaces take significantly more time to initialize than a small workspace.*

Step 11: Enter a Description for your benefit: *Any description. Note that the Description must be at least 3 characters.*

Step 12: Click **Create Research Workspace**

<figure><img src="https://2318599880-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUusNlmYiptj99Yq1UMwl%2Fuploads%2FsAIw5tJ5M468RALd2lje%2Fsagemaker_setup.gif?alt=media&amp;token=8719373b-16bd-4f42-8d80-15ebd8cf08cb" alt=""><figcaption></figcaption></figure>

</details>

{% hint style="danger" %}
When you are finished working on your workspace for the day, please STOP the workspace to avoid incurring excess cloud costs.
{% endhint %}

<details>

<summary>Wait for your Sagemaker Workspace to Initialize </summary>

* Your Sagemaker Workspace will be shown as **PENDING** until it is ready to connect
* Once your workspace is listed as **AVAILABLE**, you can connect to it
* This process should take 10-12 minutes

<figure><img src="https://2318599880-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUusNlmYiptj99Yq1UMwl%2Fuploads%2FnMAyF3E91hmc0ABfyej4%2FScreenshot%202026-05-18%20at%201.20.30%E2%80%AFPM.png?alt=media&amp;token=73f4deea-075e-4c2c-94e6-d6bd0e6fb94e" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary>Connect to your SageMaker workspace.</summary>

Step 1: Click **Connections**

Step 2: Click **Connect**.  A new tab in your internet browser will open with your SageMaker workspace.

Step 3: In the new window, select the Sagemaker Examples tab at the top of the page.

Step 4: Under the **Access to Data and Compute Using Service Workbench** section, click the **Use** button next to one of the example notebooks, such as **Connecting to OCHIN DB - R.ipynb.**&#x20;

Step 5: Click **Create Copy** on the pop-up window. NOTE: This will create a copy of ALL example notebooks listed in the **Access to Data and Compute Using Service Workbench** section, so you only need to do this action once to get access to all the notebooks.

Step 6: Select the newly created folder **Access-to-Data-and-Compute-Using-Service-Workbench**

Step 7: Select a notebook you will use to access your data. There is an example provided using R, and one using Python. It is recommended that you choose the programming language you are more comfortable with.

<figure><img src="https://2318599880-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUusNlmYiptj99Yq1UMwl%2Fuploads%2FMPLN1WyDe66x4f08DIft%2Fsagemakeer_connect.gif?alt=media&amp;token=e253cc7e-9e5e-4f96-b56a-137850908ef5" alt=""><figcaption></figcaption></figure>

</details>

{% hint style="danger" %}
In order to save your code across different Sagemaker workspaces, be sure to save code files to the **\~Sagemaker/studies/\[YOUR-PROJECT-NAME]/** folder, where your project name is the same as the study you selected at **Step 3** of this page.
{% endhint %}

## Using python to access tables in your project database

The *Connecting to Ochin Data.ipynb* notebook contains all the code needed to connect to the OCHIN Database.&#x20;

{% hint style="warning" %}
**BEFORE BEGINNING WORK:** After opening the *Connecting to Ochin Data.ipynb* notebook, you will want to save a version for yourself, as shown below.
{% endhint %}

<figure><img src="https://2318599880-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUusNlmYiptj99Yq1UMwl%2Fuploads%2FfQOoVmCwTPt7K7VmgBTW%2FScreenshot%202026-02-06%20at%2011.13.51%E2%80%AFAM.png?alt=media&amp;token=ce5d2480-a34d-4bc3-bed1-5145afc24ea9" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2318599880-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUusNlmYiptj99Yq1UMwl%2Fuploads%2FDsoJZSEDkNzRyrwHk5o5%2FScreenshot%202026-02-06%20at%2011.14.04%E2%80%AFAM.png?alt=media&amp;token=3215e6a8-b173-4c45-a173-8a7745070fa2" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2318599880-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUusNlmYiptj99Yq1UMwl%2Fuploads%2FsfK2IWbykMbSZ4zG7QLO%2FScreenshot%202026-02-06%20at%2011.14.19%E2%80%AFAM.png?alt=media&amp;token=f4f483c6-753d-4dd7-a0ec-3c498bd1b0f2" alt=""><figcaption></figcaption></figure>

#### The *Connecting to Ochin Data.ipynb* will walk you through the following steps:

1. Install necessary drivers and packages
2. Read and parse your DB credentials
3. Connect to the database
4. Query the database
   1. See the [Example Queries](/service-workbench/aim-ahead/understanding-the-ochin-data/example-queries.md) if needed for SQL assistance
5. Save a chosen subset of data to your studies folder for future analysis
