Hi,
I have a PROC SQL statement which appends 2 tables together, however, I need all the variables captured to show horizontally, any idea how to do this please?
Example (as you can see, I have all 8 variables listed from Current and Previous Tables)
Curr_email curr_first_name curr_user curr_network Prev_email Prev_first_name Prev_user Prev_network
proc sql;
create table work.cancelled_Combined AS
select
E_mail AS Curr_email,
First_Name as curr_first_name,
User_ID as curr_user,
Network as curr_network
from work.cancelled_this_month
UNION ALL
select
E_mail AS Prev_email,
First_Name as Prev_first_name,
User_ID as Prev_user,
Network as Prev_network
from work.cancelled_previous_month;
quit;
Are you looking for PROC TRANSPOSE?
https://support.sas.com/resources/papers/proceedings09/060-2009.pdf
Hi @KC_16 A mention of horizontal generally means a JOIN/MERGE. Therefore, you will have to determine whether you want to do a match-merge or an equivalent JOIN using Proc SQL.
Your code gives me the impression you are likely looking for a ONE to ONE merge, i.e
Data cancelled_Combined;
merge cancelled_this_month(rename=(the variables)) cancelled_previous_month;(rename=(the variables));/*you can write this yourself*/
run;
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.