Code Monkey home page Code Monkey logo

sas-redcap-importer's Introduction

SAS Importer for REDCap API Data

This repository documents a SAS code snippet that imports the flat REDCap database into a SAS readable dataset.

One can utilize the built-in export functions within REDCap to create a SAS-readable dataset, but this requires many manual manipulations and does not lend well to automation. Utilizing the API will allow a user to programmatically retrieve data from their REDCap database and use the data in SAS without accessing the REDCap web interface.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • REDCap database
  • SAS installed on system
  • Your unique API token provided by REDCap (do not share this with anyone!)
  • A directory to house all files created by importer

Installing

  1. Download a copy of the enclosed .sas file to the directory where you would like to save the data and resulting SAS datasets. Make sure to modify the filenames and directories within the program to locations of your choosing.
*** Text file for API parameters that define the request sent to REDCap API will be created in a DATA step ***;
filename my_in "your-directory\api_parameter.txt";

*** .CSV output file for the exported data ***;
filename my_out "your-directory\redcap_data.csv";

*** Output file of PROC HTTP status information returned from REDCap API (this is optional) ***;
filename status "your-directory\redcap_status.txt";
  1. Copy your API token into the required location for this SAS program.
*** Project- and user-specific token obtained from REDCap ***;
%let mytoken = ######; /*replace this with your token*/
  1. Replace the URL with the url for your REDCap instance.
url ="https://poa-redcap.med.yale.edu/api/" /*this can be modified to accomodate other servers/instances*/
  1. Download the SAS code from the REDCap web application and paste into the SAS program, replacing the existing template.
%macro removeOldFile(bye); %if %sysfunc(exist(&bye.)) %then %do; proc delete data=&bye.; run; %end; %mend removeOldFile; %removeOldFile(work.redcap); data REDCAP; %let _EFIERR_ = 0;
infile my_out delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=2 ;
	informat ... ;
	======================================;
	Code continues;
	======================================;
	format ...;
	run;
  1. Make the required modifications to the copied portion of the code.
*** Change INFILE name to data named in PROC HTTP OUT =, in this case my_out ***;
*** Change FIRSTOBS=1 to FIRSTOBS=2 to indicate that a header row exists ***;
*** Id desired, comment out or delete proc contents and run statement in middle of importer to prevent table being printed. ***;

Built With

  • SAS
  • REDCap API

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

This code snippet is adapted from the following publication:

Sarah Worley, Dongsheng Yang, SAS and REDCap API: Efficient and Reproducible Data Import and Export, MWSUG-2013-RX02 (https://www.mwsug.org/proceedings/2013/RX/MWSUG-2013-RX02.pdf)

sas-redcap-importer's People

Contributors

schatto1 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.