BookmarkSubscribeRSS Feed
Aniteb
Calcite | Level 5

Hi everyone,

I can't resolve this problem. I have a list of clients visits in a three months period and I need to count those visits one per client and per week. I have only today and last week's Friday dates and the dates of the clients visits.

How can I list one visit per client and per week in SAS Enterprise Guide?

Thanks for your help!

4 REPLIES 4
ballardw
Super User

Do you have any rule such as the earliest or latest visit or do you require a single random selection if there are more than one visit per week?

Aniteb
Calcite | Level 5

It can be the earliest visit. I don't have a specific rule for that, I just want to count one visit per week.

ballardw
Super User

Here is one way. A format to create groups by week within client and count, then count the result.

proc format library=work;

picture yearweek (default=8)

other= '%Y/%0U' (datatype=date);

run;

proc freq data=have noprint;

     tables client * date /list norow nocol nopercent out=temp;

     format date yearweek. ;

run;

The set TEMP will have one record per client per week.

You haven't provide an example of what the final output(s) might look like but you can get a total of clients per week by summarizing the Temp dataset variable date. A count of client would give you the total unique clients in the data.

proc freq data=temp;

tables date;

run;

Reeza
Super User

Look at the SORT Task in EG and the unique options there.

You may need to sort twice, the first time to get the data in the order you want and the second so you can take the first record.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1681 views
  • 1 like
  • 3 in conversation