Hi, I have the following source data that need to be combined and wonder if anyone could provide some thoughts on how to do it. The source data is:
Policy Var1 Var2 Var3
1234 SP500
1234 NASDAQ
1234 Russell
I want to have it look like the following:
Policy Var1 Var2 Var3
1234 SP500 NASDAQ Russell
Any ideas are appreciated!
data have;
input Policy ( Var1 Var2 Var3 ) ($);
cards;
1234 SP500 . .
1234 . NASDAQ .
1234 . . Russell
;
data want;
update have(obs=0) have;
by policy;
run;
proc print noobs;run;
Policy Var1 Var2 Var3
1234 SP500 NASDAQ Russell
data have;
input Policy ( Var1 Var2 Var3 ) ($);
cards;
1234 SP500 . .
1234 . NASDAQ .
1234 . . Russell
;
data want;
update have(obs=0) have;
by policy;
run;
proc print noobs;run;
Policy Var1 Var2 Var3
1234 SP500 NASDAQ Russell
Thank you!
Hi, if you have 1 value per variable per policy then you can do this
PROC SQL ;
CREATE TABLE want AS
SELECT policy
,MAX(Var1) AS Var1
,MAX(Var2) AS Var2
,MAX(Var3) AS Var3
FROM have
GROUP BY policy ;
QUIT ;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: