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

I want to merge flu and members data sets then remove duplicates:

 

proc sql;
create table flu
as select *
from x.personImmunization
where (cpt in
("90630" "90653" "90654" "90655" "90656" "90657" "90658" "90661" "90662" "90666" "90667" "90668" "90673" "90674" "90682" "90685" "90686" "90687" "90688" "90756"
"G0008" "Q2034" "Q2035" "Q2036" "Q2037" "Q2038" "Q2039"))
and sourceSystem="xxxx" and immunizationDate between "2020-08-01" and "2021-03-31";
quit;


/*get a list of the patients that are in the vaccination list so that we only select their proc codes*/
/*from personAttribution table*/
proc sql;
create table members
as select *
from x.personAttribution
where memberNo in (select patient_id from shp_flu)
and eligYear in (2020,2021);
quit;


/*merge flu and members tables together and bring back those that are in flu table*/

data vac_list;
merge flu (IN=A)
          members (IN=B);
by personid;
if A and B; 
run;


ERROR: BY variables are not properly sorted on data set WORK.MEMBERS.

 

1 ACCEPTED SOLUTION

Accepted Solutions
unison
Lapis Lazuli | Level 10
Hi there,
You need to order both datasets by the “by” variable(s) (personid in your case) before the merge step
-unison

View solution in original post

2 REPLIES 2
unison
Lapis Lazuli | Level 10
Hi there,
You need to order both datasets by the “by” variable(s) (personid in your case) before the merge step
-unison

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

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 2497 views
  • 1 like
  • 3 in conversation