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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 4 replies
  • 1020 views
  • 1 like
  • 3 in conversation