Hi Everyone
I would like to collapse the below records (screenshot) that have the same entity_id into one record and keep all the column values, where one is populated.
Is there a fairly straight forward way of doing this?
Paul
Hi Paul,
Try this:
proc summary data=have nway;
class entity_id;
var SubPh:;
output out=want(drop=_:) max=;
run;
Hi Paul,
Try this:
proc summary data=have nway;
class entity_id;
var SubPh:;
output out=want(drop=_:) max=;
run;
Thanks a lot Freelance! That did it.
I have not used Proc Summary before. What do the below aspects of it do?
(drop=_:) max=
Paul
Glad to read that it worked for you.
Maybe you have used (or heard of) PROC MEANS? It's almost the same, but writes to the output window by default.
The option MAX= of the OUTPUT statement says that
By default, the output dataset contains variables _TYPE_ and _FREQ_ containing additional information about the summary: In your example, _TYPE_=1 for all observations, hence not very interesting, _FREQ_ = number of observations summarized, i.e. 3 for entity_id=165771, 5 for entity_id=230674, ... Assuming that you don't need these variables, I dropped them. More precisely: I dropped all variables whose names start with an underscore.
* Here, the VAR statement contains the list of all variables in dataset HAVE whose names start with "SubPh" (assuming that these are exactly your intended analysis variables).
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.