BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
strqimr
Fluorite | Level 6

Hi guys,

I am working on a dataset with participants having multiple rows. 

I want to know if any participant have used a specific medicare item number more than once in a same day. For example participant T10002 have used "36" twice in the same date (3rd and 4th rows). 

 

4.JPGThanks mates

1 ACCEPTED SOLUTION

Accepted Solutions
jklaverstijn
Rhodochrosite | Level 12

In SQL (there are other ways) this would be:

 

proc sql;
   select participant_id, medicare_item_number, date_of_service, count(date_of_service)
   from have
   group by participant_id, medicare_item_number, date_of_service
   having count(date_of_service) > 1;

quit;

Hope this helps,- Jan.

View solution in original post

5 REPLIES 5
jklaverstijn
Rhodochrosite | Level 12

In SQL (there are other ways) this would be:

 

proc sql;
   select participant_id, medicare_item_number, date_of_service, count(date_of_service)
   from have
   group by participant_id, medicare_item_number, date_of_service
   having count(date_of_service) > 1;

quit;

Hope this helps,- Jan.

KentaMURANAKA
Pyrite | Level 9

How about

data test;
    input subject$ med item$ date$;
    datalines;
    T10002 23 A1 8/3/2009
    T10002 23 A1 10/26/2009
    T10002 36 A1 12/9/2009
    T10002 36 A1 12/9/2009
    T10002 110 A4 12/16/2009
    T10002 116 A4 1/12/2009
    ;
run;
proc sort data=test out=test_1;
    by subject item date;
run;
proc freq data=test_1 noprint;
    tables med / out=cnt;
    by subject item date;
run;
ballardw
Super User

Do you want a data set, something that goes into other procedures for analysis, or a report for humans? Do want to see the counts of everything or only the cases where there are two or more of the item on the same date?

 

And are your "dates" actually SAS date values or just character variables that look like dates?

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!

How to Concatenate Values

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.

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