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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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