Hi guys,
I currently have data such as this:
DATE CODE
196507 01384
196507 34098
196507 56565
196508 34354
196508 34353
196508 57098
I'm trying to count the number of observations within a month. So I should get
DATE COUNT
196507 3
196508 3
.
Thanks a lot guys!
.
.
.
.
Hi Benn,
Please find attached the code for the same:-
data raw;
input date code ;
datalines;
196507 01384
196507 34098
196507 56565
196508 34354
196508 34353
196508 57098
;
run;
proc sql;
create table cnt as select date,count(code) as count from raw group by date;
run;
proc print data=cnt;
run;
/Daman
Hi Benn,
Please find attached the code for the same:-
data raw;
input date code ;
datalines;
196507 01384
196507 34098
196507 56565
196508 34354
196508 34353
196508 57098
;
run;
proc sql;
create table cnt as select date,count(code) as count from raw group by date;
run;
proc print data=cnt;
run;
/Daman
we can get the same result in base sas
data test;
input DATE CODE;
cards;
196507 01384
196507 34098
196507 56565
196508 34354
196508 34353
196508 57098
;
run;
proc sort data=test;
by date;
run;
data want;
set test;
retain count;
by date;
if first.date then count=1;
else count+1;
if last.date then output want;
run;
Thanks,
Jagadish
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.