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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.