04-27-2022
cj3
Fluorite | Level 6
Member since
03-06-2020
- 12 Posts
- 5 Likes Given
- 0 Solutions
- 0 Likes Received
-
Latest posts by cj3
Subject Views Posted 1031 04-22-2022 01:25 PM 1043 04-22-2022 11:55 AM 1105 04-22-2022 08:34 AM 489 04-13-2022 09:08 AM 550 04-12-2022 12:09 PM 953 03-24-2020 04:07 PM 1010 03-23-2020 09:40 PM 1076 03-23-2020 12:34 AM 1180 03-22-2020 08:49 AM 671 03-07-2020 07:28 AM -
Activity Feed for cj3
- Posted Re: Help with PROC SQL conditional counting on SAS Programming. 04-22-2022 01:25 PM
- Posted Re: Help with PROC SQL conditional count on SAS Programming. 04-22-2022 11:55 AM
- Liked Re: Help with PROC SQL conditional count for Ksharp. 04-22-2022 11:54 AM
- Posted Help with PROC SQL conditional count on SAS Programming. 04-22-2022 08:34 AM
- Posted Re: Subsequent date-interval computation on SAS Programming. 04-13-2022 09:08 AM
- Liked Re: Subsequent date-interval computation for Kurt_Bremser. 04-13-2022 09:07 AM
- Posted Subsequent date-interval computation on SAS Programming. 04-12-2022 12:09 PM
- Posted Re: Calendar data analysis on SAS Programming. 03-24-2020 04:07 PM
- Posted Re: Calendar data analysis on SAS Programming. 03-23-2020 09:40 PM
- Liked Re: Calendar data analysis for RichardDeVen. 03-23-2020 10:54 AM
- Posted Re: Calendar data analysis on SAS Programming. 03-23-2020 12:34 AM
- Liked Re: Calendar data analysis for mkeintz. 03-23-2020 12:34 AM
- Posted Calendar data analysis on SAS Programming. 03-22-2020 08:49 AM
- Liked Re: Calendar data analysis for PaigeMiller. 03-09-2020 05:32 PM
- Posted Re: Calendar data analysis on SAS Programming. 03-07-2020 07:28 AM
- Posted Calendar data analysis on SAS Programming. 03-06-2020 11:53 PM
-
Posts I Liked
Subject Likes Author Latest Post 1 1 1 1 1
04-22-2022
01:25 PM
@HB the first entry for ID 1 has an encounter date more than 6 months before the index date. Therefore, the two dates for this observation are out of the specified range and would not count. Does this makes sense? I currently have the following code below. Do you think this is right? proc sql;
select Patient_ID,
sum((intnx('month',index_date,-6,'s')<=encounter_date<=index_date) and
(encounter_type='Telemedicine' or outpatient='Yes') ) as New_var
from have
group by Patient_ID ;
quit;
... View more
03-24-2020
04:07 PM
@mkeintz Great, thank you! I tested the code and it works except that a missing value is showing up for drugb_use at Visit 1 for subject 1. See below: Getting: PID VISITNO Date Druga_use Drugb_use 01 1 03/30/2018 1 . 01 2 05/02/2018 0 0 01 3 05/30/2018 0 0 02 1 04/09/2018 1 1 02 2 05/09/2018 1 1 02 3 . . . Instead, drugb_use at Visit 1 for subject 1 should be 0: Need: PID VISITNO Date Druga_use Drugb_use 01 1 03/30/2018 1 0 01 2 05/02/2018 0 0 01 3 05/30/2018 0 0 02 1 04/09/2018 1 1 02 2 05/09/2018 1 1 02 3 . . . Can you please let me know how the code should be modified to fix this? I have provided the datasets below for your reference. data have1;
input
pid d1date d2date d3date d4date d5date d6date d7date
d1usea d2usea d3usea d4usea d5usea d6usea d7usea
d1useb d2useb d3useb d4useb d5useb d6useb d7useb;
informat d1date d2date d3date d4date d5date d6date d7date MMDDYY8.;
format d1date d2date d3date d4date d5date d6date d7date MMDDYY8.;
informat d1usea d2usea d3usea d4usea d5usea d6usea d7usea $1.;
format d1usea d2usea d3usea d4usea d5usea d6usea d7usea $X35979X.;
informat d1useb d2useb d3useb d4useb d5useb d6useb d7useb 3.;
format d1useb d2useb d3useb d4useb d5useb d6useb d7useb 3.;
datalines;
01 . . . 02/28/18 03/01/18 03/02/18 03/03/18 . . . 0 0 1 0 . . . . . 0 .
01 03/04/18 03/05/18 03/06/18 03/07/18 03/08/18 03/09/18 03/10/18 0 0 0 0 0 1 0 . . . . . 0 .
01 03/11/18 03/12/18 03/13/18 03/14/18 03/15/18 03/16/18 03/17/18 0 1 0 0 0 0 0 . 0 . . . . .
01 03/18/18 03/19/18 03/20/18 03/21/18 03/22/18 03/23/18 03/24/18 0 0 0 0 0 0 0 . . . . . . .
01 03/25/18 03/26/18 03/27/18 03/28/18 03/29/18 03/30/18 03/31/18 0 0 1 0 0 0 0 . . 0 . . . .
01 04/01/18 04/02/18 04/03/18 04/04/18 04/05/18 04/06/18 04/07/18 0 0 0 0 0 0 0 . . . . . . .
01 04/08/18 04/09/18 04/10/18 04/11/18 04/12/18 04/13/18 04/14/18 0 0 0 0 0 0 0 . . . . . . .
01 04/15/18 04/16/18 04/17/18 04/18/18 04/19/18 04/20/18 04/21/18 0 0 0 0 0 0 0 . . . . . . .
01 04/22/18 04/23/18 04/24/18 04/25/18 04/26/18 04/27/18 04/28/18 0 0 0 0 0 0 0 . . . . . . .
01 04/29/18 04/30/18 05/01/18 05/02/18 05/03/18 05/04/18 05/05/18 0 0 0 0 0 0 0 . . . . . . .
01 05/06/18 05/07/18 05/08/18 05/09/18 05/10/18 05/11/18 05/12/18 0 0 0 0 0 0 0 . . . . . . .
01 05/13/18 05/14/18 05/15/18 05/16/18 05/17/18 05/18/18 05/19/18 0 0 0 0 0 0 0 . . . . . . .
01 05/20/18 05/21/18 05/22/18 05/23/18 05/24/18 05/25/18 05/26/18 0 0 0 0 0 0 0 . . . . . . .
01 05/27/18 05/28/18 05/29/18 . . . . 0 0 0 . . . . . . . . . . .
02 . . . . . . 03/10/18 . . . . . . 0 . . . . . . .
02 03/11/18 03/12/18 03/13/18 03/14/18 03/15/18 03/16/18 03/17/18 1 1 1 0 1 1 0 1 1 1 . 1 1 .
02 03/18/18 03/19/18 03/20/18 03/21/18 03/22/18 03/23/18 03/24/18 1 1 1 0 1 1 0 1 1 1 . 1 1 .
02 03/25/18 03/26/18 03/27/18 03/28/18 03/29/18 03/30/18 03/31/18 1 1 1 0 1 1 0 1 1 1 . 1 1 .
02 04/01/18 04/02/18 04/03/18 04/04/18 04/05/18 04/06/18 04/07/18 1 1 1 0 1 1 0 1 1 1 . 1 1 .
02 04/08/18 04/09/18 04/10/18 04/11/18 04/12/18 04/13/18 04/14/18 1 1 1 0 1 1 0 1 1 1 . 1 1 .
02 04/15/18 04/16/18 04/17/18 04/18/18 04/19/18 04/20/18 04/21/18 1 1 1 0 1 1 0 1 1 1 . 1 1 .
02 04/22/18 04/23/18 04/24/18 04/25/18 04/26/18 04/27/18 04/28/18 1 1 1 0 1 1 0 1 1 1 . 1 1 .
02 04/29/18 04/30/18 05/01/18 05/02/18 05/03/18 05/04/18 05/05/18 1 1 1 0 1 1 0 1 1 1 . 1 1 .
02 05/06/18 05/07/18 05/08/18 05/09/18 . . . 1 1 1 1 . . . 1 1 1 1 . . .
;
data have2;
input
pid Screen_Date: mmddyy10. VisitNo Visit_date: mmddyy10.;
format screen_date visit_date mmddyy10.;
datalines;
01 03/30/2018 2 05/02/2018
01 03/30/2018 3 05/30/2018
02 04/09/2018 2 05/09/2018
02 04/09/2018 3 .
;
... View more
03-07-2020
09:52 AM
1 Like
This is untested code. If you want code that I have tested, you need to provide sample data as a SAS data step.
data have2;
set have;
array drug_use d1_drug_use d2_drug_use ... ; /* You type the full list of variable names */
array dates d1_date d2_date ... ;
baseline_use_this_week=0;
do i=1 to dim(drug_use);
if drug_use(i)=1 and dates(i)<randomization_date then
baseline_use_this_week=1;
end;
run;
proc summary data=have2 nway;
class id;
var baseline_use_this_week;
output out=want max=baseline_drug_use;
run;
... View more