BookmarkSubscribeRSS Feed
KC_16
Fluorite | Level 6

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;

2 REPLIES 2
novinosrin
Tourmaline | Level 20

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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 767 views
  • 0 likes
  • 3 in conversation