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

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