BookmarkSubscribeRSS Feed
okcken
Calcite | Level 5

Hello,

I am trying to do seamless export of data from a database to SAS. I am trying to follow the Redcap model of downloading three files: SAS file, Pathway mapper and CSV file. Does anyone in the community know how to go about implementing this?

Sorry, if I am asking this question in the wrong discussion community. If I am, please direct me to the right group.

Thank you!

Ken

11 REPLIES 11
SteveDenham
Jade | Level 19

Ken, try posting to the SAS Procedures Forum.

Steve Denham

Doc_Duke
Rhodochrosite | Level 12

Ken,

What do you mean by 'seamless'?  The RedCap instructions are pretty straightforward.

I dislike the *.SAS file that redcap creates (why does every character variable need to be 500 characters wide -- that is one lazy developer!), so I had to write follow-on code to restructure the data I wanted to keep.

Doc Muhlbaier

okcken
Calcite | Level 5

Thanks, Doc Muhlbaier!

I know the instructions are very straightforward. However, I was trying to create a similar process for another application not Redcap. I know I can give access to the backend (SQL Server, MySQL) using the SAS/ACCESS component. I was also looking for an alternative method other than SAS/ACCESS. This has been a very helpful community. Thanks for all your input.

Ken

Ksharp
Super User

SQL Server, MySQL   --> CSV file or other txt file --> SAS  ,  vice versa .

sassy_seb
Quartz | Level 8

Hello Doc Muhlbaier,

 

I was having some issues with the formats that get added by default to the variables when exporting from REDCap. 

What sort of follow-on code do you do to get your intended results?  I was also noticing some issues where some variables are stored as numeric, but the output shows a string? 

 

I am new to both REDCap and SAS and am sort of stuck on this issue. Thank you

Delgoffe_MCRI
Obsidian | Level 7

@sassy_seb Check out my export macro. You can get the latest version using my REDCap survey in the previous comments or reading my paper(s) on LexJansen.com by searching "REDCap Your SAS Friend". The most recent one should be listed first.

 

To answer your question more pointedly - I've circumvented those issues by first downloading the data dictionary via API and using it to define features instead of the code REDCap provides as an export option. This is even more important with the use of style characters in values now.

 

I will also be presenting new content on REDCap at the SESUG Conference in Bethesda September 22-24th (2024). Registration is still open - as is call for content.

https://sesug.org/SESUG2024/index.php 

DCMarks25
Fluorite | Level 6

I am just starting to explore the data export, cleaning and report generation elements in REDCap. The back end looks like a big hot mess to me.  Will the process you outlined in your paper work on complex projects with repeating instruments and longitudinal aspects? I built my projects but the back end is overwhelming to me. I have a childhood Lead Poisoning Surveillance project that has around 3500 variables(not all needed for reporting) with 4 longitudinal pieces (for environmental investigation activities only) and repeating instruments throughout the project. I have included a screenshot of most of the build

 

Screenshot 2026-08-20 123637.pngScreenshot 2026-08-20 123637.png

Delgoffe_MCRI
Obsidian | Level 7

You will want to explore a Limited Fields Extract or first create a Report in REDCap and then export that report.

 

I have presented several times and published many versions of the normal export process (exports all fields but does work for all REDCaps including complex ones like yours), Limited fields (where you specify which fields), or Report Based (exporting from a report you already created in REDcap) exports. 

 

You can obtain all of those using my REDCap survey here: https://redcap.link/REDCapIsMySASFriend.

 

If you'd prefer - you can also join/meet me at the Midwest SAS Users Group Conference, where I am the operations chair this year, November 15-17th, 2026 in Madison, WI and I can be your code doctor for a custom solution! Check it out at www.mwsug.org.

Delgoffe_MCRI
Obsidian | Level 7

I have recently published a macro to export REDCap data into SAS along with formats and a data dictionary. Please see my paper, presentation, and code by filling out this survey: https://redcap.link/REDCapIsMySASFriend.

 

Distribution using this method allows me to distribute only the most recent version, so you can check back to this survey in the future as well.

Tom
Super User Tom
Super User

Thanks.

A quick glance at the code and the main benefit of the macros seems to be to automate the API call to retrieve the data dictionary and the data.  So that you could initiate an extract from RedCap via code instead of the user interface.

 

I noticed you did include a simplified method of checking the downloaded CSV file to insure that there are no embedded CRLF pairs in any of the variable values.

 

Are there any other smarts in the macro also that make working with the format that RedCap exports the data easier?  That is understanding the meaning of the data dictionary and using that to convert the data as exported into a structure more suitable for working with in SAS? 

 

 

Delgoffe_MCRI
Obsidian | Level 7

Yes, it uses regular expressions to remove HTML, carriage returns, and completely parses the REDCap data dictionary to provide labels and formats to the SAS dataset it creates.

 

At times you may need to control how it interprets the type of variable it makes based on existing data (ESPECIALLY with missing data codes), but the next version under development will go through and replace text missing data codes with numeric acceptable values before import to avoid that...so stay tuned!

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch Now →
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 11 replies
  • 9958 views
  • 0 likes
  • 8 in conversation