09-05-2024
rox26
Calcite | Level 5
Member since
05-23-2024
- 7 Posts
- 0 Likes Given
- 0 Solutions
- 0 Likes Received
-
Latest posts by rox26
Subject Views Posted 520 08-07-2024 08:33 AM 608 08-06-2024 04:28 PM 691 07-23-2024 09:29 AM 959 07-19-2024 03:57 PM 796 05-23-2024 02:22 PM 797 05-23-2024 02:20 PM 849 05-23-2024 11:30 AM -
Activity Feed for rox26
- Posted Re: Select highest count of consecutive months with respect to a starting date on SAS Programming. 08-07-2024 08:33 AM
- Posted Select highest count of consecutive months with respect to a starting date on SAS Programming. 08-06-2024 04:28 PM
- Posted Re: Redefine variables in macro statement by incremental years on SAS Programming. 07-23-2024 09:29 AM
- Posted Redefine variables in macro statement by incremental years on SAS Programming. 07-19-2024 03:57 PM
- Posted Re: Copy range of data from one column to another with different starting columns on SAS Programming. 05-23-2024 02:22 PM
- Posted Re: Copy range of data from one column to another with different starting columns on SAS Programming. 05-23-2024 02:20 PM
- Posted Copy range of data from one column to another with different starting columns on SAS Programming. 05-23-2024 11:30 AM
08-07-2024
08:33 AM
There are two different spans of consecutive enrollment in this one case. One is 12/2020 to 1/2021 and the other is 3/2021 to 6/2021. I need the count of the first span (2nd row) because it contains the month of diagnosis (12/2020). Most of my other cases are continuously consecutive, so I was just taking the last row of each but here is an instance where that doesn't work.
... View more
08-06-2024
04:28 PM
I want to create an indicator for the row of data for each person that is the highest count of consecutive months of insurance BUT that also includes the month of diagnosis in that span. In an example of one case, I have information about the enrollment status in insurance for the month of diagnosis and the 6 months after. The month of diagnosis is 12/2020 and they are enrolled that month and the next month (1/2021). However, they are not enrolled in insurance the following month (2/2021). They are enrolled again in insurance 3/2021 through 6/2021. I have created the counts of consecutive months of insurance with the 2 consecutive spans. I now need to create an indicator that will show which row (per person) has the highest count of consecutive months of insurance while in the same consecutive span as the diagnosis month. This one case has a situation where the highest count of consecutive insurance is in a different date span than the diagnosis date. I've tried different combinations of first last but it's not doing the trick. Here's the code and the screenshots of the tables: *data of one person with 2 different consecutive spans; data have; input id dx_date :ddmmyy10. enroll_date :ddmmyy10. insurance consec_months; format dx_date ddmmyy10. enroll_date ddmmyy10.; datalines; 99 12/01/2020 12/01/2020 1 1 99 12/01/2020 01/01/2021 1 2 99 12/01/2020 03/01/2021 1 1 99 12/01/2020 04/01/2021 1 2 99 12/01/2020 05/01/2021 1 3 99 12/01/2020 06/01/2021 1 4 ; run; proc print data=have; run; *manually showing the output I want for the indicator; data want; set have; if enroll_date='01JAN2021'd and consec_months=2 then want_indicator=1; else want_indicator=0; run; proc print data=want; run; Thank you!
... View more
07-23-2024
09:29 AM
Thanks so much, this worked.
... View more
07-19-2024
03:57 PM
I have a dataset with years 2000-2019 and one variable for each year with the state that reported the data (e.g., STATE_2000, STATE_2001, STATE_2002). I need to populate a variable with the reporting state for each month and year of the data instead of just by year. For example, if I have STATE_2000, I need one for each month like STATE_012000, STATE_022000, STATE_032000, etc. This will just be a copy of the STATE_2000 variable with a new name, 12 times over for each year. I am trying to find a way to succulently write the code instead of writing it all out like this because I have 20 years of data: data do_not_want; set have; STATE_012000=STATE_2000; STATE_022000=STATE_2000; STATE_032000=STATE_2000; run; I tried playing around with a macro for the month but I don't think it likes the underscore. I think I figured out a way to do it with a macro statement for the year but it's only outputting the last year. Here's an example with a couple of years of data: %macro state_yrs; %do yr=2000 %to 2002; data want; set have; STATE_01&yr=STATE_&yr; STATE_02&yr=STATE_&yr; STATE_03&yr=STATE_&yr; STATE_04&yr=STATE_&yr; STATE_05&yr=STATE_&yr; STATE_06&yr=STATE_&yr; STATE_07&yr=STATE_&yr; STATE_08&yr=STATE_&yr; STATE_09&yr=STATE_&yr; STATE_10&yr=STATE_&yr; STATE_11&yr=STATE_&yr; STATE_12&yr=STATE_&yr; run; %end; %mend state_yrs; %state_yrs; The output is giving me the variable name I want (STATE_MMYYYY), but in this example, it's only outputting the year 2002 and not 2000 or 2001. Thank you!
... View more
05-23-2024
02:22 PM
I thought using a simple dataset would be easier but I also didn't want to leave out the background explanation. I see how this is confusing. I will take this into consideration next time, thanks.
... View more
05-23-2024
02:20 PM
The latter works perfectly with my real data, thank you SO much!
... View more
05-23-2024
11:30 AM
I'm conducting an analysis on SAS 9.4 with health insurance enrollment data and want to understand the enrollment patterns before and after a diagnosis. I have monthly data for several years which I want to select 24 rolling months based around a diagnosis date. I want to copy over the select months into new columns based on the start month range. I have a dummy example below where month1-month7 are the enrollment months 1 through 7 and start_month is the number of the start month and end _month is the number of the end month of the range. I want to copy the data into the "next" variables for a range of 4. Adding "output" into the code doesn't solve the issue. The desired output at the end of this code. Thank you! *table creation for 2 examples; data try1; input month1-month7 start_month end_month; datalines; 1 2 3 4 5 6 7 2 4 1 2 3 4 5 6 7 4 7 ; run; proc print data=try1; run; *This straight copies the data into the "next" variables, not based on start/end range; data try2; set try1; array month month1-month7; /*enrollment months*/ array next next1-next4; /*want to copy over select months here*/ do i=1 to 4; /*interested in range of 4 months*/ next{i}=month{i}; /*this straight copies the data*/ end; run; proc print data=try2; run; *HERE IS WHERE I AM STUCK; *Trying to copy the select months based on the start and end range; *This code below only copies the last select month, which is wrong; data try3; set try1; array month month1-month7; /*enrollment months*/ array next next1-next4; /*want to copy over select months here*/ do k=start_month to end_month; /*start month and end month for each person*/ do i=1 to 4; /*interested in range of 4 months*/ next{i}=month{k}; /*this code is incorrect, it just copies the last month */ end; end; run; proc print data=try3; run; /*This is the desired output*/ data want; input month1-month7 start_month end_month next1-next4; datalines; 1 2 3 4 5 6 7 2 4 2 3 4 . 1 2 3 4 5 6 7 4 7 4 5 6 7 ; run; proc print data=want; run;
... View more