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

9 REPLIES 9
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 

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!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register 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
  • 9 replies
  • 5069 views
  • 0 likes
  • 7 in conversation