That's over-optimistic I reckon. An updated message and documentation is all we'll get.
Here's a version that works when you have many variables, not just 2 or 3:
proc sort data=have;
by case_id state;
run;
data want;
update have (obs=0) have;
by case_id;
run;
It also works when you have many observations per CASE_ID.
@Astounding, you may end up with unwanted results with UPDATE
data have;
input case_id state1 $ state2 $;
datalines;
1 A .
1 . .
1 . B
;
proc sort data=have;
by case_id state1 state2;
run;
data want;
update have (obs=0) have;
by case_id;
run;
proc print; run;
Obs case_id state1 state2 1 1 A B
@PGStats, you're right about the possibility of complications. But it's difficult to tell what is really necessary here. The original post is likely to be a simplification of the actual scenario so I wanted to make sure the UPDATE program was at least considered. The example that you posted might actually be a desirable result ... it's up to the original poster to decide.
Note that I had the data set sorted by STATE so that non-missing-values the non-missing STATE observation would prevail if there is a conflict.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.