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

Good evening everyone. I have a result table I created after some joins and analysis. My table has provider number, treatment code, facility name. For the most records, each provider number has one facility name attributed to it, but in few cases there are multiple facility names for unique combination of provider number and treatment code. I want to identify those and just keep the first occurring facility name and remove the second record. 

Have:

prov_num   tc_code  fac_nm   

01                a            abc          

01                a             abc_1     

01                b              abc_1

03                c              def

03                c               def_1

 

Want:

prov_num   tc_code  fac_nm   

01                a            abc          

01                b             abc_1

03                c              def

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
heffo
Pyrite | Level 9

Something like this?

proc sort data=sashelp.class nodupkey out=want dupout=dont_want;
	by sex age; 
run;

Potentially you might want to sort it first on prov_num, tc_code and fac_nm. Then another sort with no dupkey on prov_num and tc_code like in the above example. 

View solution in original post

3 REPLIES 3
heffo
Pyrite | Level 9

Something like this?

proc sort data=sashelp.class nodupkey out=want dupout=dont_want;
	by sex age; 
run;

Potentially you might want to sort it first on prov_num, tc_code and fac_nm. Then another sort with no dupkey on prov_num and tc_code like in the above example. 

ballardw
Super User

If your have set is grouped/ sorted as implied then perhaps:

 

data want;
   set have;
   by notsorted prov_num notsorted tc_code;
   if first.tc_code;
run;
devsas
Pyrite | Level 9

@heffo @ballardw  thanks to both of you. Both solutions work.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 625 views
  • 7 likes
  • 3 in conversation