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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.