Closes #3. SAS now handles instrument status fields

This commit is contained in:
Egeler, Paul W 2018-06-04 20:47:09 -04:00
parent 57a0538a11
commit 3f891fcfef

View File

@ -49,9 +49,8 @@
%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 */,
KEY = RECORD_ID /* Variable that links base table with other tables */
DATA_DICTIONARY = REDCAP_DATA_DICTIONARY /* The name of the SAS dataset of the data dictionary */
);
/* Remove formatting from repeat instrument field */
@ -83,13 +82,23 @@
%IF &N_SUBTABLES GT 0 %THEN %DO;
/* Make a list of fields and their associated forms based on data dictionary */
/* Get information on the variables in the dataset */
PROC CONTENTS
DATA = &DATA_SET.
OUT = REDCAP_VARNAMES(KEEP=NAME)
OUT = REDCAP_VARNAMES(KEEP=NAME VARNUM)
NOPRINT;
RUN;
/* Find the key that links the base table to child tables */
DATA _NULL_;
SET REDCAP_VARNAMES;
IF VARNUM EQ 1 THEN DO;
CALL SYMPUT("KEY", NAME);
STOP;
END;
RUN;
/* Make a list of fields and their associated forms based on data dictionary */
DATA REDCAP_FIELDS(KEEP=VAR_NAME FORM_NAME);
SET &DATA_DICTIONARY.;
IF FIELD_TYPE EQ "checkbox" THEN DO;
@ -105,6 +114,20 @@
ELSE OUTPUT;
RUN;
/* Add instrument status fields to list of fields */
PROC SQL;
CREATE TABLE REDCAP_INSTRUMENT_STATUS_FIELDS AS
SELECT DISTINCT TRIM(FORM_NAME)!!"_complete" AS VAR_NAME LENGTH=200, FORM_NAME
FROM REDCAP_DATA_DICTIONARY;
QUIT;
PROC APPEND
BASE=REDCAP_FIELDS
DATA=REDCAP_INSTRUMENT_STATUS_FIELDS;
RUN;
/* Sort out the field names */
PROC SQL NOPRINT;
@ -151,6 +174,11 @@
%END;
/* Clean up temporary datasets */
PROC DATASETS MEMTYPE=DATA LIBRARY=WORK NOLIST;
DELETE REDCAP_FIELDS REDCAP_VARNAMES REDCAP_INSTRUMENT_STATUS_FIELDS;
RUN;
%END;
%ELSE %DO;