Hey all, I'm currently attempting to create a rather large dataset so here is an overview of the general steps I'm thinking I can take, how I plan to actually do it and then the issues I'm noticing so far. My first steps are to merge together 6 datasets (data from 2012-2017, 1 year per dataset) using proc sql then create dummy variables to denote certain disease diagnoses. After I create those dummy variables I need to create two different "flag" variables that add together some of these dummy variables. After I have these flag variables I can toss the dummy variables for cleanliness purposes. The problem I'm running into is the following: The datasets of 2012-2017 data have 1 observation for every visit to the hospital by that ID. One goal is to create dummy variables assigning a '1' to an individual when they have one visit in a year. We only want patients that were seen at least once every year from 2012-2017, but if I create a dummy variable by each year, I'm having trouble actually telling SAS to add these dummy variables back together in a manner where I only add 1 once, per year, for the 5 years. Ideally I'm hoping to take this information, which has potentially hundreds of visits per year per person, and create a variable that (at max!) would equal 6, telling me that they made at least 1 visit per year across all 6 years being measured. I attempted to create an array but it just added together all the dummy variables for that ID within that year, rather than reading all years. Here is the code (ge1_x is just my dummy variable that should assign a 1 for 1 visit within that year): data utilization1; set utilization; by corp_id; years=0; array score {6} ge1_12 ge1_13 ge1_14 ge1_15 ge1_16 ge1_17; do i=1 to 5; if score{i}=1 then years=years+1; if score{i}=0 then years=years+0; if score{i}=. then years=.; end; run; The variables I have to work with are ID, discharge_date (I used this to create ge1_x above), and discharge_year. I'm think discharge_year may be the easier variable to do this with though. Hopefully that makes a bit of sense. Any advice is greatly appreciated!
... View more