Hello,
New-ish SAS user here.
I want to count the number of events that occur by year, sex, and age_group. I have attached two data sets where "sample1" represents my data and "sample2" represents what I need for a final product.
Using the code below, SAS will count the number of events but is combining age groups. For example, during 2003 combines the events for age_group=3 into the count of events for age_group=3 for state=27.
/* count code */
proc sort data = one;
by year state;
run;
data two;
set one;
by year state ;
if first.state then count = 0;
count + 1;
if last.state;
keep year count Sex age_group;
run;
"Sample1" represents my data and "Sample2" represents the what I want in a final product.
Thank you!
Hi @psnorrod
Could you please put your sample data directly in the question as many of us won't download files due to security issues.
Thank you!
Yes, thank you for the reminder @ed_sas_member
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.