I want to create a variable to include all data under the variables PROC1, PROC2, PROC3, PROC4, and PROC5 that have a code starting with "361". it looks like this:
PATIENT_ID AGE ADMITDATE SYSTOLIC PROC1 PROC2 PROC3
1 1 72 28-Apr-10 97 3610 1135 3813
2 2 78 17-Mar-10 81 1253 3402 5113
3 3 77 28-Oct-10 142 5233 2965 3150
4 4 85 21-Nov-10 99 4422 4682 6490
5 4 66 24-Sep-10 98 4444 5513 5051
6 5 68 8-Jul-10 175 1299 3454 1816
7 6 68 6-Jun-10 124 7399 1782 4667
8 6 89 7-Jul-10 184 3639 3794 7610
9 7 70 28-Feb-10 117 2009 3058 1077
10 7 85 3-May-10 99 6919 3276 8857
11 9 80 29-Sep-10 43 7609 4866 4202
12 9 66 5-Sep-10 182 5164 6403 3810
13 10 72 13-Feb-10 138 8684 8154 3568
(I only showed a few observations and up to PROC3 because of spacing)
I used the function select() to select the appropriate data but I want to select all PROC variables(PROC1-5) and select for data starting with 361. However, I am not sure how to do that. My code is below:
newUSNtest_data <- newUSNtest_data %>% select(PROC1, startsWith(361))
Any tips?