BookmarkSubscribeRSS Feed
yahoo0806
Calcite | Level 5

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!

4 REPLIES 4
Reeza
Super User

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!


 

yahoo0806
Calcite | Level 5

My data looks like this. Please see attached.

Reeza
Super User
Sorry, I can't download attachments from online services. Please refer to the link I provided on how to provide usable data for others to be able to help you.
Jagadishkatam
Amethyst | Level 16

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;
Thanks,
Jag

sas-innovate-white.png

Register Today!

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.

Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 818 views
  • 0 likes
  • 3 in conversation