diff --git a/README.md b/README.md index 4a1056b..1d229a2 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ records, so no pre-processing of metadata csv is needed. THIS LINE: ```format redcap_repeat_instrument redcap_repeat_instrument_.;``` 1. Run the RECapRITS macro definitions in the source editor or using `%include`. -1. Run the macro call `%REDCAP_READ_DATA_DICT()` to load the data dictionry into your SAS session, pointing to the file location of your REDCap data dictionary. +1. Run the macro call `%REDCAP_READ_DATA_DICT()` to load the data dictionary into your SAS session, pointing to the file location of your REDCap data dictionary. 1. Run the macro call `%REDCAP_SPLIT()`. You will have an output dataset for your main table as well as for each repeating instrument. diff --git a/REDCap_split.r b/REDCap_split.r index 6f35fb5..a7fbbf6 100644 --- a/REDCap_split.r +++ b/REDCap_split.r @@ -4,8 +4,8 @@ #' and give individual tables for each repeating instrument. Metadata #' is used to determine which fields should be included in each resultant table. #' -#' @param records data.frame containing the records -#' @param metadata data.frame containing the metadata +#' @param records \code{data.frame} containing project records +#' @param metadata \code{data.frame} containing project metadata (the data dictionary) #' @author Paul W. Egeler, M.S., GStat #' @examples #' \dontrun{ @@ -35,9 +35,11 @@ #' returnFormat = 'json' #' ) #' +#' # Convert JSON to data.frames #' records <- fromJSON(result.record) #' metadata <- fromJSON(result.meta) #' +#' # Split the data.frame into a list of data.frames #' REDCap_split(records, metadata) #' } #' @return a list of data.frames diff --git a/REDCap_split.sas b/REDCap_split.sas index 727e62d..690f455 100644 --- a/REDCap_split.sas +++ b/REDCap_split.sas @@ -21,13 +21,13 @@ * format redcap_repeat_instrument redcap_repeat_instrument_.; * * 2. Download the data dictionary for your project. - +* * 3. Run the macro definitions REDCAP_READ_DATA_DICT and REDCAP_SPLIT * -* 3. Run the macro call for REDCAP_READ_DATA_DICT to load in the data dictionry. +* 4. Run the macro call for REDCAP_READ_DATA_DICT to load in the data dictionry. * This is necessary to split the tables correctly. * -* 4. Run the macro call for REDCAP_SPLIT. You will have an output dataset for +* 5. Run the macro call for REDCAP_SPLIT. You will have an output dataset for * your main table as well as for each repeating instrument. * ********************************************************************************/ @@ -44,7 +44,7 @@ IF FIELD_TYPE EQ "descriptive" THEN DELETE; - DROP SECTION_HEADER X1-X14; + DROP SECTION_HEADER FIELD_TYPE X1-X14; RUN; @@ -53,7 +53,7 @@ %MACRO REDCAP_SPLIT( DATA_DICTIONARY = REDCAP_DATA_DICTIONARY /* The name of the SAS dataset of the data dictionary */, - DATA_SET = REDCAP/* The name of the SAS dataset created by REDCap */, + DATA_SET = REDCAP /* The name of the SAS dataset created by REDCap */, KEY = RECORD_ID /* Variable that links base table with other tables */ );