Hi all,
I'm trying to produce a month by month enrollment summary based on the subject's randomization date (Mainly: month and year) and April 2021.
The results I want to produce is like below:
random_date first month 2nd month ...... xx month
May-2018 xx xx xx
Jun -2018 xx xx xx
xx is the number of subjects
I can only get my current program go this far:
data intv; set enroll_data;
enddate = '30APR2021'd;
startdate = input(compress(date_randomized,'-'),date7.);
nmonths = intck('month', startdate, enddate);
run;
In order for me to achieve that goal, can you please suggest how I should build up my program?
Many thanks!
What does your input data set look like?
Otherwise we don't know how your data is structured and how it can be used to get what you need.
Here are instructions on how to provide sample data as a data step:
https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...
If you can't upload your actual data, please generate some fake data instead and upload that, it just needs to be in similar format and structure. For example, if you need to deal with multiple groups, have a few in the sample data.
@yahoo0806 wrote:
Hi all,
I'm trying to produce a month by month enrollment summary based on the subject's randomization date (Mainly: month and year) and April 2021.
The results I want to produce is like below:
random_date first month 2nd month ...... xx month
May-2018 xx xx xx
Jun -2018 xx xx xx
xx is the number of subjects
I can only get my current program go this far:
data intv; set enroll_data;
enddate = '30APR2021'd;
startdate = input(compress(date_randomized,'-'),date7.);
nmonths = intck('month', startdate, enddate);run;
In order for me to achieve that goal, can you please suggest how I should build up my program?
Many thanks!
My data looks like this. Please see attached.
Could you please try the below code, i am not sure if we need to use APRIL 2021
data have;
input subject_ID$ randomization_date:date9.;
month_year=substr(put(randomization_date,date11.),4);
month=month(randomization_date);
cards;
100001 21-Apr-18
100002 05-Jun-18
100003 08-Aug-18
100004 11-Sep-19
100005 20-Oct-19
100006 30-Apr-19
100007 05-Jan-19
100008 14-Dec-18
100009 13-Nov-18
100010 15-Jul-19
100011 28-Aug-18
100012 04-Oct-18
100013 20-Sep-18
100014 22-Oct-18
100015 08-Nov-18
100016 15-Nov-18
100017 12-Nov-18
100018 14-Nov-18
100019 05-Dec-18
100020 04-Jan-19
100021 07-Jan-19
100022 11-Mar-19
100023 26-Mar-19
100024 28-Mar-19
100025 06-Aug-19
100026 16-Aug-18
100027 09-Aug-18
100028 08-Oct-18
100029 10-Dec-18
;
proc means data=have n nway noprint;
class month_year month;
output out=count n=n;
run;
proc sort data=count;
by month_year;
run;
proc transpose data=count out=want;
by month_year;
id month;
var n;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.