For example, in the following code notice how the table data_join contains multiple copies of the z values for A001 and B002.
Is it possible to just retain the first row of values from the matched data2 table? I'm outputting joined tables to Excel and so it's easier on the eyes if there aren't so many duplicate rows.
data data1;
input id :$4. x y;
cards;
A001 10 20
A001 30 40
A001 50 60
B002 1 2
B002 3 4
B002 5 6
;
run;
data data2;
input id :$4. z;
cards;
A001 1000
B002 2000
;
run;
proc sql;
create table data_join as
select *
from data1 a
inner join
data2 b
on a.id=b.id;
quit;
Use PROC REPORT for the export:
ods xlsx file="/somewhere/file.xlsx";
proc report data=join;
column id x y z;
define id / group;
define x / display;
define y / display;
define z / group;
run;
ods excel close;
Untested, posted from my tablet.
Use PROC REPORT for the export:
ods xlsx file="/somewhere/file.xlsx";
proc report data=join;
column id x y z;
define id / group;
define x / display;
define y / display;
define z / group;
run;
ods excel close;
Untested, posted from my tablet.
In that case I like this macro.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.