Under the scenario that I have a multiple selection variable that will end up becoming multiple variables when imported into SAS, I have come up with a solution to my problem. The code below first starts with what the data would look like if imported into SAS, where the variable "v" originally was just one "v" variable but offered the user the option to select more than one choice. After the users have selected more than one option in variable "v", the data is exported from REDcap and imported into SAS, which REDcap then spreads "v" out into "v1", "v2", "v3", etc, and codes everything as 0s or 1s based on whether or not an option was selected. This makes for a very wide dataset and you I can't do the PROC FREQ I need to do on 30 different variables. I need ONE table with ONE row variable and ONE column variable. **v1-v5 is a variable where users can input all the different kinds; **of plastic surgery they have had. 0s for unselected, 1s for selected.;
DATA have;
INPUT v1 v2 v3 v4 v5 InsuranceStatus;
DATALINES;
0 1 0 1 1 0
0 0 0 0 0 0
1 1 0 1 1 0
1 1 1 1 1 1
1 0 0 0 1 1
0 1 1 0 0 0
1 1 1 0 1 1
0 0 1 1 0 1
;
RUN;
**Using CAT to concatenate the spread out "v" variable into one; **variable called "result". However, CAT only returns a character; **variable and I need it to be numeric. The code below converts; **"result" to Z5 numeric format in a new variable called "result2";
DATA want; set have;
format result2 Z5.;
result = cat(of v1-v5);
put result $char.;
result2 = result;
RUN;
**A bunch of 0s and 1s is not very readable for humans. Labeling ; **them below ensures I understand what they mean;
PROC FORMAT library = work;
value ResultLabel
01011 = "Diep procedure"
00000 = "none"
11011 = "DIEP + tissue"
11111 = "All selected"
10001 = "tissue + flap"
01100 = "nipple + flap"
11101 = "something else"
00110 = "lots of surgeries";
run;
/*The PROC FREQ below gives me the one table that I want */
PROC FREQ DATA = want;
TITLE "Types of plastic surgeries";
FORMAT result2 ResultLabel.;
TABLES result2 * InsuranceStatus / nopercent;
RUN;
... View more