Hello,
I want an advice on the best way to calculate counts of testing for each month/year.
So my data looks as below. I want the count of testing for each month.year.
Patient tests service date
1 1 31Jan1992
1 1 23Jul1995
2 1 04Feb1992
I want to calculate the testing count for each month in each year, so I have count for Jan, 1992 and for Feb 1992, till the latest record for 2015. the same patient may have different testing at different dates.
Can I sort by date first and then make a do loop of first. service date and last.service and make the sum of testing. ? Any advice how best to tackle this?
Thank you so much, looking forward to hear back from you.
Best,
Lamia
Do you have duplicates you ned to account for? If not, then you can use PROC FREQ?
proc freq data=have;
format service_date yymon7.;
table service_date / out= want;
run;
You can merge them back in, or if you want them directly in you could probably use SQL.
Note that you didn't state that initially so I'm going to leave that step up to you.
@lamiaH wrote:
Thank you so much for your reply. I will try this, but I need the counts to
be within the data and not a result and for every month/year. I want to use
them later in another step. Would this work?
Thanks
@lamiaH wrote:
Thank you so much for your reply. I will try this, but I need the counts to
be within the data and not a result and for every month/year. I want to use
them later in another step. Would this work?
Thanks
You may want to provide a few more lines of example data and then what the resulting data set you want would look like at the end for those given values.
Hi again,
So inorder to put this formate within the data , I 've created a nother date variable and
date=servdate;
format date yymon7.;
run;
so it gave me this format within the same data.
Thanks again
Lamia
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 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.