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

That's over-optimistic I reckon. An updated message and documentation is all we'll get.

Astounding
PROC Star

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.

PGStats
Opal | Level 21

@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
PG
Astounding
PROC Star

@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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 18 replies
  • 1383 views
  • 7 likes
  • 7 in conversation