BookmarkSubscribeRSS Feed
coco1908
Calcite | Level 5

Good Morning,

 

I have the following data below (first 10 observations).

Enrolled Frequency

06/02/20141
10/09/20142
10/16/20144
10/17/20143
10/18/20141
10/20/20145
10/21/20142
10/22/20141
10/27/20144
10/28/20141

I need to convert the total frequency into weeks with cumulative summary of enrolled:

Week         Enrolled

6/2/2014    1

6/9/2014    1

...               ...

10/6/2014  1

10/13/2014 3

10/20/2014 16

10/27/2014  23

5 REPLIES 5
Reeza
Super User

I'm not following how you're doing the translation between days/weeks. Can you please expand your example.

coco1908
Calcite | Level 5

I need to convert the frequency into a cumulative frequency by weeks of the year. 

coco1908
Calcite | Level 5
I still need to collapse this into weeks though to get the second part of my question.
DanZ
Obsidian | Level 7
data have;
format date week mmddyy10.;
input date mmddyy10. enroll;
week = intnx('week',date,0,'begin')+1;
cards;
06/02/2014	1
10/09/2014	2
10/16/2014	4
10/17/2014	3
10/18/2014	1
10/20/2014	5
10/21/2014	2
10/22/2014	1
10/27/2014	4
10/28/2014	1
;
run;
data want(drop=i rc date enroll);
if _n_ = 1 then do;
	if 0 then set have;
	declare hash h (dataset:'have',multidata:'y');
	h.definekey('week');
	h.definedata('enroll');
	h.definedone();
end;
call missing (of _all_);
do date = '01jan2014'd to '31dec2014'd by 7;
	week = intnx('week',date,0,'begin')+1;
	rc=h.find();
	do i = 1 to 10 while (rc=0);
		enroll_tot + enroll;
		rc=h.find_next();
	end;
	output;
end;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 814 views
  • 0 likes
  • 3 in conversation